When an item is clicked, its path is sent as parameter to state
function and the state function does $state.go
to load a state with the passed path as parameter.
This doesn't seem to work. What am I missing here?
<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" } } });
handler.get("/home").then(function(response) {
looks like a promise to me. Try moving $scope.state
definition outside this promise.
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
});
}
}
])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.