首页 文章

离子页面更改

提问于
浏览
0

我是离子和角度js的新手,有人可以提供帮助 . 我花了两天时间创建从一个页面到另一个页面的链接但是失败了 .


这是默认标签页上的按钮,如(短划线) . 这是我的控制器:

.controller('DashCtrl', function($scope) {

       $scope.create = function () {
       alert("new post");
      $scope.go('templates/newspost');
  };

})

这是我的路线

.state('newspost', {
    url: '/newspost',
    abstract: true,
    templateUrl: 'templates/newspost.html'
  })

我不知道我哪里弄错了 .

2 回答

  • 0

    你也可以试试这个:

    <button class="button button-icon ion-compose" ui-sref="newspost">New Posts</button>
    

    或者您也可以使用锚标记:

    <a href="#/newspost">New Post</a>
    

    希望它能帮到你!!

  • 0

    我认为你的语法错误 .

    .controller('DashCtrl', function($scope) {
       $scope.create = function () {
       alert("new post");
      $scope.go('templates/newspost');  };})
    

    你应该写$ state.go('templates / newspost')而不是$ scope.go('templates / newspost')你还应该将$ state添加到.controller这样的函数中

    .controller('DashCtrl', function($scope,$state)

相关问题