【问题标题】:redirect to a view after successful save in ionic在离子中成功保存后重定向到视图
【发布时间】:2016-02-11 14:46:10
【问题描述】:

成功保存ng-submit表单后如何重定向到另一个视图

控制器

.factory('Post', function($resource) {
  return $resource('api/add_new_order',{name: "@name", phone: "@phone"});
})
.controller('ContactCtrl', function($scope, Post, Authorization) {

  // Get all posts
  $scope.posts = Post.query();
  // Our form data for creating a new post with ng-model
  $scope.postData = {};
  $scope.newPost = function() {
    var post = new Post($scope.postData);
    post.$save();

  }
$scope.issues = {};
$scope.answer = function(){
    console.log($scope.issues.name);
}
$scope.postData = Authorization;
})

【问题讨论】:

    标签: angularjs ionic-framework


    【解决方案1】:

    这取决于您使用的路由。 Ionic 默认是 ui-router 包。您首先必须在应用程序的config 块中定义不同的$states(-> 参见here)。然后您可以在控制器中注入$state 服务,$state.go() 方法将执行“重定向”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-12
      • 1970-01-01
      • 2019-05-12
      • 2013-02-15
      • 2018-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多