我在AngularJS路由和控制器中遇到问题.这是代码:
的index.html
<!DOCTYPE html> <html ng-app="contacts"> <head> <script src="libs/angular.min%20(1).js"></script> <script src="contacts.js"></script> <script src="index.js"></script> <title></title> </head> <body > <div data-ng-view=""></div> </body> </html>@H_301_5@index.js
var myApp = angular.module('contacts',[]); myApp.config(function ($routeProvider) { $routeProvider .when('/',{ controller: 'ContactsCtrl',templateUrl: '/views/show-contacts.html' }) //.when('/view2',{ controller: 'MyCont',templateUrl: 'V2.htm' }) .otherwise({ redirectTo: '/' }); });@H_301_5@contacts.js
var myApp = angular.module('contacts',[]); myApp.controller('ContactsCtrl',function ($scope) { $scope.name = "omar"; });@H_301_5@但我收到这个错误:
Argument ‘ContactsCtrl’ is not a function,got undefined
有帮助吗?