Jav*_*der 1 javascript javascriptmvc angularjs
现在我们在调用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;
});
});
};
}
Run Code Online (Sandbox Code Playgroud)
我在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;
});
});
}
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?
除了那个曾经工作(第二个实现)我想显示活动的属性,如果我试图得到这样的属性它不起作用:
<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>
Run Code Online (Sandbox Code Playgroud)
但是,如果我试图获得像{{action}}这样的整个对象,我实际上可以看到所有条目.
将控制器更改为
function MainCtrl($scope, DataService, $location) {
$scope.getActionList = function() {
DataService.getActions(function(results) {
$scope.$apply(function() {
$scope.actionList = results;
});
});
};
$scope.getActionList();
}
Run Code Online (Sandbox Code Playgroud)
然后,如果你想重新加载actionList电话getActionList()
| 归档时间: |
|
| 查看次数: |
2716 次 |
| 最近记录: |