我正在尝试将此变量传递给控制器,然后在屏幕上显示。我不确定为什么我会因为这个值而未定义。我去了类似的SO问题,似乎我做得对。
.state({
name: "test",
url: "/testURL",
views: {
'testView': {
template: '<div><span>{{testvariable}} </span></div>',
controller: "testController",
resolve: {
testString: function () {
debugger;
return 'from Resolve';
}
}
}
},
})
})
app.controller("testController", ["$scope", "$state",
function ($scope, $state, testString) {
console.log("getting from resolve ", testString)
$scope.testvariable = function () {
console.log("getting from resolve ", testString)
return testString;
}
$scope.testvariable();
}
])