2016-05-05 5 views
1

Ich versuche, dynamische Links von der Json zu meiner iframe Vorlage zu laden. Wenn ich die Iframe-Seite lade, erscheint dieser Fehler. Ich weiß nicht wirklich warum. Dies ist das erste Mal, dass ich diesen Fehler gesehen habe. Hier ist der Code unten.

-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 Vorlage

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

apps Symbol Vorlage

<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'}"> 

Antwort

1

Sie nicht Interpolation Richtlinie innerhalb eines ng-Stil Richtlinie Ausdruck haben können, müssen Sie korrigieren es gefällt mir unten.

<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

0

fixiert ich das Problem. Ich habe den Code in meinem Controller geändert und es hat perfekt funktioniert.

app.controller('apps', [ 
'$scope', 
'$http', 
'contentService', 
'gotoService', 
'getIndex', 
'$routeParams', 
'$sce', function($scope, $http, contentService, gotoService, getIndex, $routeParams, $sce){ 
    contentService.then(function(data){ 
    $scope.data = data; // access all 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 $sce.trustAsResourceUrl($scope.appsList[$scope.indexRoute].url); 
    } 
}); 

}]); 
Verwandte Themen