ng-view,我收到一个错误:检查目标崩溃了 在index.html中,有一个带有ng-view的div
<div ng-app="rootscope">
<div ng-view></div>
</div>
在js中
var rootscope = angular.module('rootscope',['ngRoute','ngTouch']);
rootscope.config(['$routeProvider',function($routeProvider){
$routeProvider.
when('/main',{
templateUrl: 'views/route/main.html',
controller: 'mainCtrl'
}).
when('/',{
templateUrl: 'views/route/login.html',
controller: 'indexCtrl'
}).
otherwise({redirectTo: '/'});
}]);
控制器js
rootscope.controller('homeCtrl',function($scope,$location) {
$scope.login = function(){
$location.path('/main');
};
});
所以首先我们将进入登录视图。然后单击登录按钮,应该进入主视图,在主视图中我想做一些像index.html,div可以更改。但是,你看到我的控制器js
<div id="main">
<div>
<div ng-view></div>
</div>
<div>
unchanged
</div>
</div>