【发布时间】:2015-05-17 09:42:37
【问题描述】:
我正在尝试在 angular.js (1.3.15) 中路由并遇到这两个错误:
错误消息
1-WARNING: Tried to load angular more than once. 2-angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=after_login& p1=Err…0d%20(http%3A%2F %2Flocalhost%3A49062%2FScripts%2Fangular.min.js%3A17%3A381)
我的模块.js
var after_login = angular.module("after_login", ['ngRoute', 'CrackWeb']);
after_login.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/groups',
{
templateUrl: 'Views/p1.cshtml',
controller: 'MyScripts/groups'
})
.otherwise(
{
redirectTo: '/'
});
$locationProvider.html5Mode(true).hashPrefix('!');
}]);
在我编写的带有 ng-app 的 html 页面中。
p1.cshtml [部分]
<div class="col-md-9">
<br />
<input ng-model="check" id="ch"/>
{{check}}
<div ng-view></div>
</div>
谁能帮忙?
【问题讨论】:
-
控制器怎么样?
-
after_login.controller('groups', function ($scope) { $scope.login = function (userName, pass) { alert(userName+pass); var url = '52.11.190.113/api/account/login'; $http.post(url, { email:userName, password:pass, deviceregistrationid: '67788' }) .success(function (data,$location){ alert("success"+" "+ data.message); }) ; } });
-
您是否在 html 中添加了 ng-app="after_login" ??
-
这是我添加的
标签: javascript angularjs html twitter-bootstrap