[英]AngularJS: Can not change location using routes
I am learning Angular and this is what I try to do 我正在学习Angular,这就是我想要做的
I have a demo here, which says on console that I am routing
, but doesn't routes it 我在这里有一个演示,该演示在控制台上显示
I am routing
,但没有路由
The relevant code is 相关代码是
$scope.deleteSession = function() {
// console.log('deleting session');
$cookieStore.remove('session');
updateSession();
$scope.route();
};
$scope.route = function () {
console.log('I am routing');
$location.path('/route');
}
The full code/demo is here 完整的代码/演示在这里
Please help me understanding my mistake 请帮助我理解我的错误
Add ng-view
attribute to your body
: 将
ng-view
属性添加到您的body
:
<body ng-controller="MainCtrl" ng-view >
Have a look: http://plnkr.co/edit/6eIt6F?p=preview 看看: http : //plnkr.co/edit/6eIt6F?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.