2016-05-05 12 views
1

ダイナミックリンクをjsonからiframeテンプレートに読み込もうとしています。 iframeページを読み込むと、このエラーがポップアップします。私はなぜそれが本当にわからない。このエラーが発生したのは今回が初めてです。以下にコードを示します。

コントローラ

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

答えて

1

あなたはNGスタイルのディレクティブ表現の内部に補間ディレクティブを持つことができない、あなたは修正する必要がありますそれは以下のようです。

<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

私は問題を修正しました。コントローラのコードをこれに変更したところ、完全に機能しました。

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); 
    } 
}); 

}]); 
関連する問題