现在我们所面临的问题在调用对DataService(解析)控制器调用,问题是,这个代码不工作:
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}}这样的整个对象,我可以看到所有条目。
任何错误在控制台 – 2013-03-23 11:21:18
我看到的第一个问题是两种功能:和数组被命名为因为'DataList'是角应用程序的一部分时'actionList' – 2013-03-23 11:26:13
不应该使用'$ .apply'。标记中的{{action.get()}}'没有意义。为什么从'DataService'返回的数组中的对象在其中具有函数...或者它们是做什么的?在ng-repeat标记中只需要{{Action}}。显示'DataService'模块或工厂的代码 – charlietfl 2013-03-23 13:53:50