我有一个像这样的AngularJS指令:
MyDirective = (myService) ->
templateUrl: 'my-partial.html'
compile: () ->
pre: ($scope, $element, $attrs, $controller) ->
$attrs.$observe 'myDirective', (name) ->
success = (response) ->
$scope.entries = response
failure = () ->
console.log "Failed to load data for #{name}"
myService.loadData(name)
.then success, failure
MyDirective.$inject = ['MyService']
和部分:
<ul>
<li data-ng-repeat="entry in entries">
<img src="{{entry.url}}">
</li>
</ul>
在将其添加到 DOM 之前,如何编译模板,从而用...src="{{entry.url}}"...
正确的图像替换?src
问题是我们在异步调用接收到数据之前收到了一些 404 错误,我们希望避免这些错误。