I am currently working on my App.js file which contains the following code snippet:
var app = angular.module('githubApp', []);
In addition to that, I have a githubAppController with the following code block:
app.controller('githubController', function ($scope, $http) {
$scope.submit = function () {
var promise = $http.get('https://api.github.com/users/odetocode');
promise.then(onUserGet);
var onUserGet = function (response) {
$scope.user = response.data;
};
};
});
Furthermore, within my page.html file, the following code is present:
<!DOCTYPE html>
<html >
<head>
<title></title>
<meta charset="utf-8" />
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<link href="Content/custom.css" rel="stylesheet" />
<script src="Scripts/jquery-1.9.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="Scripts/jquery.validate.min.js"></script>
<script src="Scripts/App.js"></script>
<script src="Scripts/githubController.js"></script>
</head>
<body ng-app="githubApp">
<div ng-controller="githubController">
<form class="form-horizontal" ng-submit="submit()">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" id="submit" class="btn btn-primary" value="Submit" />
<input type="reset" id="submit" class="btn btn-primary" value="Reset" />
</div>
</div>
</form>
<div class="col-sm-5">
<label>{{user.name}}</label>
</div>
<div class="col-sm-7">
<a ng-href="{{user.blog}}">{{user.company}}</a>
</div>
<div>
<img ng-src="{{user.avatar_url}}" />
</div>
</div>
However, I am facing an issue where the ng-submit directive does not trigger the $scope.submit function. Can you please assist me in identifying what might be causing this problem?
var app = angular.module('githubApp', []);
app.controller('githubController', function($scope, $http) {
$scope.submit = function() {
var promise = $http.get('https://api.github.com/users/odetocode');
promise.then(onUserGet);
var onUserGet = function(response) {
$scope.user = response.data;
};
};
});
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
</head>
<body ng-app="githubApp">
<div ng-controller="githubController">
<form class="form-horizontal" ng-submit="submit()">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" id="submit" class="btn btn-primary" value="Submit" />
<input type="reset" id="submit" class="btn btn-primary" value="Reset" />
</div>
</div>
</form>
<div class="col-sm-5">
<label>{{user.name}}</label>
</div>
<div class="col-sm-7">
<a ng-href="{{user.blog}}">{{user.company}}</a>
</div>
<div>
<img ng-src="{{user.avatar_url}}" />
</div>
</div>
Any help or suggestions would be greatly appreciated. Thank you.