我正在尝试以 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',
...
关于javascript - 如何将一个 View 移动到具有不同路径文件的 Angular 另一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27939497/