简体   繁体   English

AngularJS:无法使用路线更改位置

[英]AngularJS: Can not change location using routes

I am learning Angular and this is what I try to do 我正在学习Angular,这就是我想要做的

  • Add a session on a button click of 'Add Session' 单击“添加会话”按钮添加会话
  • Delete session on a button click of 'Delete Session' and redirect it to different page 单击“删除会话”按钮删除会话,然后将其重定向到其他页面

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM