相关疑难解决方法(0)

如何在Angular 2中设置iframe src而不会导致`unsafe value`异常?

我是没有AngularJS经验的Angular 2的新手,并且正在编写一个涉及设置iframe src属性的教程:

<iframe width="100%" height="300" src="{{video.url}}"></iframe>
Run Code Online (Sandbox Code Playgroud)

这引发了一个异常:

Error: unsafe value used in a resource URL context
at DomSanitizationServiceImpl.sanitize...
Run Code Online (Sandbox Code Playgroud)

我已经尝试过使用绑定但iframe没有成功.我可能错过了一些东西,我很难找到解决方案.

angular

144
推荐指数
5
解决办法
14万
查看次数

在RC.1中,使用绑定语法无法添加某些样式

风格如

<div [style.background-image]="\'url(\' + image + \')\'">Background</div>
<div [style.transform]="rotate(7deg)"
Run Code Online (Sandbox Code Playgroud)

不再添加

css angular

68
推荐指数
1
解决办法
5万
查看次数

$ sce.trustAsResourceUrl()全局

我该怎么做这样的事情: $sce.trustAsResourceUrl('URL_HERE');

在全球范围内,就像在主应用程序config()run()函数中一样,任何iFrame,img src等都URL_HERE可以使用吗?

文档在解释这一点时相当差.

angularjs

42
推荐指数
3
解决办法
5万
查看次数

获取谷歌地图链接与纬度/经度

我想获得谷歌地图链接,显示位于纬度/经度的标记中的标题/内容.

所以参数是标题,内容,纬度,经度.结果是这样的链接 https://maps.google.com/?ie=UTF8&ll=xxx,xxx&title=xxx&content=xxx

我搜索谷歌并没有在谷歌API中找到答案,事件.

google-maps

25
推荐指数
3
解决办法
9万
查看次数

Angular 2 - EXCEPTION:错误:资源URL上下文中使用的不安全值

我收到以下错误:

Angular 2 - EXCEPTION:错误:资源URL上下文中使用的不安全值

是否与在启动时不立即使用媒体项目有关?或者它与URL不安全有关?我正在努力消毒它.

export class HomeComponent {

  sanitizer: DomSanitizationService;
  errorMessage: string;
  activeMedia: MediaItem = new MediaItem(0, '', '', '', '', '', '');

  constructor(
    private mediaStorage: MediaStorageService, 
    private harvesterService: HarvesterService, 
    sanitizer: DomSanitizationService) {

    this.sanitizer = sanitizer;
    // Initial call - 
    harvesterService.getMediaItems(10, 'type', 'category');
    let subscription = harvesterService.initialMediaHarvestedEvent.subscribe(() => {
      this.activeMedia = mediaStorage.mediaList[0];
      let newURL = this.activeMedia.URL + '?rel=0&autoplay=1';
      newURL = newURL.replace('watch?v=', 'v/');
      this.activeMedia.URL = newURL; //sanitizer.bypassSecurityTrustUrl(newURL);
      console.log(newURL);
    });
  }

  cleanURL(oldURL: string): SafeResourceUrl {
    return this.sanitizer.bypassSecurityTrustUrl(oldURL);
  }
}
Run Code Online (Sandbox Code Playgroud)

模板代码是: …

javascript typescript angular

25
推荐指数
1
解决办法
2万
查看次数

错误错误:在 angular 2 中的资源 URL 上下文中使用了不安全的值

我有以下 HTML 代码

<iframe #originalUrl [hidden]="!showOriginalDoc"  [src]="originalUrl"><span *ngIf="originalUrl===''">Original URL Not Available</span></iframe>
Run Code Online (Sandbox Code Playgroud)

以下角度代码

 if(data.originalResearch.originalUrl===null)
  this.originalUrl='';
 else
  this.originalUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(data.originalResearch.originalUrl);
Run Code Online (Sandbox Code Playgroud)

上面的代码仍然抛出以下错误:

CuratorModalBodyComponent.html:123 错误错误:在 DomSanitizerImpl.vendor../node_modules/@angular/platform-b​​rowser/@angular的资源 URL 上下文中使用了不安全的值(参见http://g.co/ng/security#xss) /platform-b​​rowser.es5.js.DomSanitizerImpl.sanitize (platform-b​​rowser.es5.js?ffb0:3992) at setElementProperty (core.es5.js?0445:9398) at checkAndUpdateElementValue (core.es5.js?0445:9318) ) at checkAndUpdateElementInline (core.es5.js?0445:9252) at checkAndUpdateNodeInline (core.es5.js?0445:12357) at checkAndUpdateNode (core.es5.js?0445:12303) at debugCheckAndUpdateNode (core.es5.js?0445) :13167) 在 debugCheckRenderNodeFn (core.es5.js?0445:13146)

我正在使用 angular 4.4.1

angular

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×4

angularjs ×1

css ×1

google-maps ×1

javascript ×1

typescript ×1