javascript - 如何将一个 View 移动到具有不同路径文件的 Angular 另一个 View ?

标签 javascript angularjs angularjs-directive angularjs-scope angular-ui-router

我正在尝试以 Angular 将一个 View 移动到另一个 View 。实际上,我能够显示第一个 View 。并且在该 View 中有一个按钮。单击按钮时,我试图转到下一页,但我收到错误按钮点击为什么?

这是我的笨蛋 http://plnkr.co/edit/2cMimMX6xS0rTB7lJOQx?p=preview

(function() {
  'use strict';

  angular
    .module('firstApp')
    .controller('firstcont', firstcont);

  firstcont.$inject = ['$scope',"$state"];
  function firstcont($scope,$state) {
    $scope.clickEvent=function(){
     $state.go('/second')
    }
  }

})();

最佳答案

updated working plunker state.go 需要状态名称

function firstcont($scope,$state) {
    $scope.clickEvent=function(){
     // instead of this
     // $state.go('/second')
     // we need this
     $state.go('secondapp')
    }
}

因为您的州定义为:

$stateProvider
    .state('secondapp', {
        url: '/second',
        ...

检查updated version here

关于javascript - 如何将一个 View 移动到具有不同路径文件的 Angular 另一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27939497/

相关文章:

javascript - 重置时区感知时间戳 momentjs

javascript - react Formik : how to use custom function onChange and onConfirmChange for request input

javascript - AngularJS : ngRepeat scope fails in custom directive with isolated scope and ngTransclude

angularjs:将焦点设置在指令内先前隐藏的输入元素上

angularjs - 命名 Angular 指令(ng- 与 data-ng-)

javascript - 想要在我的 ASP.NET MVC 项目中实现自动完成功能

javascript - 使用 .bind() 回退测试 .on()

javascript - 如何在 AngularJS 中处理实时数据和查看状态

javascript - 无法找到资源 - Tomcat - Spring - AngularJS

javascript - 为什么简单地使用 ng-init 和 delete 会产生语法错误?