我试图重复数组中的一些数字并希望在颜色框中输出,但由于某种原因我看不到数组中的数字。我没有转义任何特殊字符或缺少连接吗?谢谢
$scope.someNumber = [1,2,3,4];
jQuery.colorbox({html:"<div ng-model= 'someNumber' ng-repeat='number in someNumber'>{{number}}</div>"});
最佳答案
将 $compile
注入(inject) Controller ,然后执行以下操作:
jQuery.colorbox({html:$compile("<div ng-model= 'someNumber' ng-repeat='number in someNumber'>{{number}}</div>")($scope)});
原因是必须编译html才能让AngularJS检索/计算表达式并使其正常工作,否则Angular无法知道发生了什么
关于javascript - ngRepeat 在 colorbox 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31047534/