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

补充

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

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

即 注入 $location 和

 $location.path("your page");
原文地址:https://www.cnblogs.com/xieyier/p/3982046.html