做一个循环回路内的一个观点:
<tr ng-repeat="result in results">
<td>
<span ng-repeat="device in helpers.getIosDevices(result.ios_device)">
{{ device.code }}
</span>
</td>
</tr>
控制器:
$scope.helpers = CRM.helpers;
助手:
var CRM = CRM || {};
CRM.helpers = {
// Handle "111" value format
getIosDevices: function (devices) {
var obj = [];
if (devices !== null && devices !== undefined) {
if (devices.charAt(0) === '1') {
obj.push({
code: 'ipod',
name: 'iPod',
});
}
if (devices.charAt(1) === '1') {
obj.push({
code: 'ipad',
name: 'iPad',
});
}
if (devices.charAt(2) === '1') {
obj.push({
code: 'iphone',
name: 'iPhone',
});
}
}
return obj;
}
};
得到这个错误:https://docs.angularjs.org/error/ $ rootScope/infdig?p0 = 10 & p1 =%5B%5B%22fn:%E2%80%A620%20%20%7D;%20newVal:%20undefined;%20oldVal:%20undefine d%22%5D%5D
据我所知,但我不知道如何解决它在我的情况。我应该使用哪种解决方法?
那么如何重写这个以避免异常呢?在大多数情况下,创建的数组总是相同的。 – Syl 2014-11-03 09:20:13
@sylouuu增加了一些演示 – 2014-11-03 09:38:27
谢谢你的作品! – Syl 2014-11-03 09:56:17