控制器代码
myApp.controller("BaseController", ["$scope", function($scope) {
$scope.imgProcessingUrl = appUrl + "Images/ajax-loader.gif";
}
]);
此处appUrl为http://localhost/sample/public/
Html代码
<img id="imgProcessing" ng-src="{{imgProcessingUrl}}" style="display:none;">
master.blade.php
<script>
var appUrl = "{!! URL(''); !!}/";
</script>
问题是:网页总是显示如下所示的渲染html。
<img id="imgProcessing" style="display:none;">
我错过了什么吗?
答案 0 :(得分:1)
要使控制器范围内的全局变量可用,您必须将浏览器$window
对象作为依赖项传递。
myApp.controller("BaseController", ["$scope", "$window", function($scope, $window) {
$scope.imgProcessingUrl = $window.appUrl + "Images/ajax-loader.gif";
}
]);