ionic goto other page or alert

有时候需要 调试,这是就需要alert 的...可惜的是我不会angular  所以记录一下

.controller('mainctr', function($scope, $window) {
$window.alert('xxxxx');
})

只需要 $window 就可以了;

跳转页面的时候,$state.go(to [, toParams] [, options]) ;同时加入 $location, $state

.controller('registerctr', function($scope,$location, $state) {
$scope.gopage=function(){
$state.go("app.login"); //$state.go(to [, toParams] [, options])
}
})

而在路由器 选择这里app.js

  .state('app.login', {
url: "/login",
views: {
'menuContent' :{
templateUrl: "templates/login.html",
controller: 'loginctr'
}
}
})

2014-09-24 17:37:49

补充

今天浏览了一些博客 我有发现了一下跳转页面的代码

 youapp.controller('LoginController', function($scope, $location, $ionicViewService) {
$scope.login = function(password) {
//控制你按下返回键时,跳转到原来的页面 这对Login页面不好 当然是随你了
$ionicViewService.nextViewOptions({
disableAnimate: true,
disableBack: true
});
$location.path("/app/protected");
}
});

即 注入 $location 和

 $location.path("your page");
上一篇:设置Android Studio启动时可选最近打开过的工程


下一篇:UVA 1001 Say Cheese 奶酪里的老鼠(最短路,floyd)