我遇到了一個問題,試圖將參數對象傳遞給使用stage.go()的狀態。angularjs狀態參數不起作用
這裏是我的狀態定義:
.state('drillhole.ddhinttype', {
url: '/ddhinttype',
templateUrl: VIRTUAL_DIR_PATH + '/App/Views/drillholemanager/drillhole/tabddhinttype.html?v=' + fileVer,
controller: 'DrillHoleDdhIntTypeController',
params: { name: null, description: null }
})
這裏是我的控制器:
try {
angular.module('centric.drillhole.manager');
} catch (e) {
angular.module('centric.drillhole.manager', ['app.config', 'ui.router', 'kendo.directives', 'ui.bootstrap', 'ngCookies', 'centric.common', 'centric.notification', 'pascalprecht.translate', 'centric.security', 'centric.app.settings']);
}
angular.module('centric.drillhole.manager').controller('DrillHoleDdhIntTypeController', ['$scope', 'CentricUIHelper', 'NumberHelper', 'DrillHoleManagerService', 'app.config', '$stateParams',
function ($scope, uihelper, numberHelper, service, appconfig, $stateParams) {
$scope.loading = false;
$scope.isbusy = function() {
return $scope.loading || $scope.$parent.loading;
}
var load = function() {
var hello = $stateParams.name;
var hello2 = $stateParams.description;
};
load();
}]);
我打電話,像這樣的狀態:
$state.go('drillhole.ddhinttype', { name: tab.params.name, description: tab.params.description });
在我的控制器名稱和說明屬性始終爲空。
不知道我在這裏錯過了什麼。有任何想法嗎?
您是否通過調試器驗證過「tab.params.name」和「tab.params.description」是否爲空? –
是的,我確實檢查過。價值在那裏。 – Ian