单击某个项目时,其路径作为参数发送到state
函数,状态函数执行$state.go
以加载状态,并将传递的路径作为参数。
这似乎不起作用。我在这里缺少什么?
<div ng-click="state(item.class, item.path, item.mime_type)">
controller("groupsListCtrl", ["$scope", "handler", "$state",
function($scope, handler, $state) {
handler.get("/home").then(function(response) {
$scope.data = response;
$scope.items = $scope.data.inventory;
$scope.state = function(stateType, objectPath, mimeType) {
$state.go("workarea.user", {
path: objectPath
});
}
})
}
])
.state("workarea.user", {
url: "^/workarea/:path",
requireLogin: true,
views: {
"options": {
templateUrl: "/views/options.html",
controller: "optionsCtrl"
},
"workspace": {
templateUrl: "/views/workspace.html",
controller: "workspaceCtrl"
},
"comments": {
templateUrl: "/views/comments.html",
controller: "commentsCtrl"
}
}
});
答案 0 :(得分:0)
handler.get("/home").then(function(response) {
看起来像是对我的承诺。
尝试将$scope.state
定义移到此承诺之外。
controller("groupsListCtrl", ["$scope", "handler", "$state",
function($scope, handler, $state) {
handler.get("/home").then(function(response) {
$scope.data = response;
$scope.items = $scope.data.inventory;
});
$scope.state = function(stateType, objectPath, mimeType) {
$state.go("workarea.user", {
path: objectPath
});
}
}
])