Reputation: 5
I'm new at AngularJS, started 2 days ago, but I can't resolve this problem.
It seems that my directive ng-controller can't find my controller.
Here is my code :
<section class="index" ng-app="indexApp" ng-controller="cRegister">
<form>
<input type="text" ng-model="username" />
<input type="password" ng-model="password" />
<input type="submit" ng-click="" />
</form>
<script>
var app = angular.module('indexApp', [])
app.controller('cRegister', ['$scope', function() {
console.log('controller: true');
}]);
</script>
</section>
(This is a part of the main page, that I displayed with ng-view) :
<html ng-app="web">
<head>
<title>AngularJS, tries</title>
<meta charset="utf-8">
</head>
<body>
<div ng-view></div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.min.js"></script>
<script src="https://code.angularjs.org/1.6.2/angular-route.min.js"></script>
<script>
var app = angular.module('web', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'partials/index.php'
})
.otherwise({
redirectTo: '/'
})
});
</script>
</body>
</html>
Hope someone could help me, thank you ! :D
Upvotes: 0
Views: 69
Reputation: 3047
you cannot have two ng-app directive in one html. remove the inner one and add that controller to the first ng-app
Upvotes: 3