现在我们在调用 DataService (Parse) 的控制器中面临一个问题,问题是这段代码不起作用:
function MainCtrl($scope, DataService, $location)
{
$scope.actionList = function() {
// Call the service and fetch the list of signatures that match the given action ID
DataService.getActions(function (results) {
$scope.$apply(function () {
// Apply the results to the signatureList model so it will refresh the table in the view
$scope.actionList = results;
});
});
};
}
我在 DataService 行中放置了一个断点,但它没有被命中,但是如果我以这种方式实现 Ctrl ,它确实会被调用并且它可以工作!!:
function MainCtrl($scope, DataService, $location)
{
// Call the service and fetch the list of signatures that match the given action ID
DataService.getActions(function (results) {
$scope.$apply(function () {
// Apply the results to the signatureList model so it will refresh the table in the view
$scope.actionList = results;
});
});
}
知道为什么会这样吗?
除此之外,一旦工作(使用第二个实现)我想显示活动的属性,如果我尝试像这样获取属性它不起作用:
<div id="wrapper"><div id="scroller">
<div ng-controller="MainCtrl">
<ul id="thelist">
<li ng-repeat="action in actionList">{{action.get('Action')}}</li>
</ul>
</div>
</div></div>
但是,如果我尝试获取像 {{action}} 这样的整个对象,我实际上可以看到所有条目。