如何在离子空白应用程序中配置状态?

时间:2015-04-28 06:49:33

标签: angularjs cordova ionic-framework ionic

我创造了一个新的离子空白应用程序,有两个html页面:1 index.html和category.html。我配置了状态,然后在app.js文件中添加了控制器,但它无法正常工作。

这是我的州配置:

.config(function($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('camera',{
            url:"/camera",
            cache: false,
            controller:"CameraCtrl",
            templateUrl:'index.html'
        })
        .state('category', {
            url: "/category",
            templateUrl: "category.html",
            controller: 'CategoryCtrl'
        })

    // if none of the above states are matched, use this as the fallback

    $urlRouterProvider.otherwise('/camera');

})

这是我的控制者:

.controller('CameraCtrl',function($scope,$state){
  $scope.menu = function() {
    console.log('yesytest');
      $state.go('category');
      // window.location = "category.html";
  };

})

这是我的app.js.这里有什么不对吗?

1 个答案:

答案 0 :(得分:0)

不幸的是,我只有15分钟时间一起嘲笑这个,让我知道这是否适合你,如果你需要任何进一步的帮助,请给我回复。

控制器

{{1}}

>>> Working Example <<<