gpt4 book ai didi

javascript - AngularJS错误: $interpolate:interr Interpolation Error with $routeParams

转载 作者:行者123 更新时间:2023-11-27 23:01:34 28 4
gpt4 key购买 nike

我正在尝试将动态链接从 json 加载到我的 iframe 模板中。当我加载 iframe 页面时,会弹出此错误。我真的不知道为什么。这是我第一次看到这个错误。下面是代码。

Controller

app.controller('apps', [
'$scope',
'$http',
'contentService',
'gotoService',
'getIndex',
'$routeParams', function($scope, $http, contentService, gotoService, getIndex, $routeParams){
contentService.then(function(data){
$scope.data = data; // access all data
$scope.appsList = $scope.data.appsList; // list of shortcuts

// change url to links
$scope.goTo= function(url){
gotoService.getLink(url);
}

// get index
$scope.getIndex = function(index){
getIndex.current(index);
}

// embed in iframe
$scope.link = function(){
$scope.indexRoute = $routeParams.index;
return $scope.appsList[$scope.indexRoute].url;
}
});

}]);

iframe 模板

<iframe ng-controller="apps" ng-src="{{link()}}" width="800"   height="600">
</iframe>

应用程序图标模板

<div class="apps-background" ng-click="goTo(a.link+'/'+$index); getIndex($index);" ng-style="{'background-image':'url({{a.image}})', 'background-repeat': 'no-repeat', 'background-size': 'cover'}">

最佳答案

您不能在 ng-style 指令表达式中包含插值指令,您需要像下面这样更正它。

<div class="apps-background" 
ng-click="goTo(a.link+'/'+$index); getIndex($index);"
ng-style="{'background-image': 'url('+ a.image + ')', 'background-repeat': 'no-repeat', 'background-size': 'cover'}">

Similar answer

关于javascript - AngularJS错误: $interpolate:interr Interpolation Error with $routeParams,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37044287/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com