如何当src网址是角范围内加载脚本?范围内、脚本、加载、网址

由网友(冷心冷血冷感情)分享简介:我试图让一些自定义的脚本加载存储在依赖于在客户端的一些逻辑,我有数据库。我的问题是如何去上班。我的控制器: 使用严格的;angular.module('youshareApp')    .controller('ShareCtrl',['$范围,$ routeParams','Projectservice',函数($范...

我试图让一些自定义的脚本加载存储在依赖于在客户端的一些逻辑,我有数据库。我的问题是如何去上班。

我的控制器:

 使用严格的;angular.module('youshareApp')    .controller('ShareCtrl',['$范围,$ routeParams','Projectservice',函数($范围,$ routeParams,Projectservice){ $ scope.projectId = $ routeParams.projectId; $ scope.model.url =/ API / V1 /项目/ code /+ $ scope.projectId;...}]); 

我的观点:

 < D​​IV CLASS =容器NG-控制器=ShareCtrl的风格=的margin-top:50px​​的; >< H3>目前您正在促进:LT; / H3 GT&;< D​​IV CLASS =行的风格=的margin-top:10px的;>    < D​​IV CLASS =COL-MD-6><标签类=引领> {{model.name}}< /标签>< / DIV>< / DIV>< D​​IV CLASS =行的风格=的margin-top:10px的;>    < D​​IV CLASS =COL-MD-6>< p =班领导> {{model.description}}< / P>< / DIV>< / DIV><脚本NG-SRC = {{model.url}} />< / DIV> 

我如何才能让这项工作?

我也试过这个post

梦貂蝉辅助软件下载 梦貂蝉小黑辅助破解版下载v2.38 最新版 当易网

通过这个模板:

 < D​​IV HTML绑定不安全='HTML'>< / DIV> 

这在控制器:

  $ scope.html ='<脚本的src =+ $ scope.model.url +'/>'; 

解决方案

您必须声明的网址是安全的。你可以通过阅读一下就在这里: https://docs.angularjs.org/error/ $ SCE / insecurl

这可能会发生的另一件事是,你不使用NG-SRC。

I'm trying to get some custom script to load that is stored in the database depending on some logic i have on client side. My problem is how to get to work.

My controller:

'use strict';
angular.module('youshareApp')
    .controller('ShareCtrl',['$scope','$routeParams' ,'Projectservice',function     ($scope,$routeParams,Projectservice) {
 $scope.projectId=$routeParams.projectId;
 $scope.model.url="/api/v1/project/code/"+$scope.projectId;
...

}]);

My view:

<div class="container" ng-controller="ShareCtrl" style="margin-top: 50px;" >
<h3>You are currently contributing to : </h3>

<div class="row" style="margin-top: 10px;">
    <div class="col-md-6"><label class="lead">{{model.name}}</label></div>
</div>

<div class="row" style="margin-top: 10px;">
    <div class="col-md-6"><p class="lead" >{{model.description}}</p></div>
</div>
<script ng-src={{model.url}} />
</div>

How could i make this work?

I also tried this post

With this in the template:

    <div html-bind-unsafe='html'></div>

And this in the Controller:

    $scope.html='<script src="'+$scope.model.url+'" />';

解决方案

You must declare the url to be safe. You can do that by reading a bit on it here : https://docs.angularjs.org/error/$sce/insecurl

another thing that could be happening is that you are not using ng-src.

阅读全文

相关推荐

最新文章