试图通过angularjs

时间:2015-09-18 05:37:09

标签: angularjs soundcloud

我正在使用Soundclouds api获取uri / permalink_url,然后使用他们的嵌入布局,但我一直收到此错误。

Error: [$interpolate:noconcat] Error while interpolating: https://w.soundcloud.com/player/?url={{sound.uri}}
Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required.  See http://docs.angularjs.org/api/ng.$sce
http://errors.angularjs.org/1.4.5/$interpolate/noconcat?p0=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3D%7B%7Bsound.uri%7D%7D
    at REGEX_STRING_REGEXP (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:68:12)
    at Function.$interpolateMinErr.throwNoconcat (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:10727:9)
    at $interpolate (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:10979:30)
    at addAttrInterpolateDirective (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:8587:27)
    at collectDirectives (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:7724:13)
    at compileNodes (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:7551:22)
    at compileNodes (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:7567:15)
    at compileNodes (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:7567:15)
    at compileNodes (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:7567:15)
    at compileNodes (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.js:7567:15) <div ui-view="" class="ng-scope">

在我添加的模板中

<iframe ng-src="https://w.soundcloud.com/player/?url={{sound.uri}}"></iframe>

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

使用$sce服务 样本实施

function AppCtrl($scope, $sce) {
    // ...
      var sampleUrl = "https://w.soundcloud.com/player/?url=any_value"
      $scope.displayUrl = $sce.trustAsResourceUrl(sampleUrl);
}

在HTML端

<iframe ng-src="{{displayUrl}}"> </iframe>