我正在尝试使用DomSanitizer来清理组件中的动态URL,我似乎无法弄清楚为此服务指定Provider的正确方法是什么.
我正在使用Angular 2.0.0-rc.6
这是我目前的组成部分:
@Component({
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
providers: [ DomSanitizer ],
})
export class AppComponent implements OnInit
{
public url: SafeResourceUrl;
constructor(private sanitizer: DomSanitizer) {}
ngOnInit() {
let id = 'an-id-goes-here';
let url = `https://www.youtube.com/embed/${id}`;
this.videoUrl = this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
ngOnDestroy() {}
}
Run Code Online (Sandbox Code Playgroud)
这会导致this.sanitizer.bypassSecurityTrustResourceUrl is not a function运行时出错.
有人能告诉我一个如何正确提供DomSanitizer提供商的例子吗?谢谢!
javascript typescript angular-services angular angular-dom-sanitizer
我一直在使用带有SVG的DomSanitizer的html字符串.
在当前版本的Angular之前,这个工作得很好:
this.domSanitizer.bypassSecurityTrustHtml(content);
现在我得到一个叫做的对象
SafeHtmlImpl {changingThisBreaksApplicationSecurity: "<svg> blah </svg>"}
changingThisBreaksApplicationSecurity
Run Code Online (Sandbox Code Playgroud)
现在是否有新的方法来访问DomSanitizer的输出?我应该以SafeHTML类型或其他方式接收它吗?如果它仍然过滤html,那么拥有bypassSecurityTrustHtml有什么意义呢?
明信片上的任何答案?请...
我有移动应用程序REST API调用,无需任何令牌或安全机制即可访问我的服务器.
我想保护我的API调用.我正在尝试了解什么是OAuth以及它如何保护我的移动应用REST API调用到我的服务器?
另外,我想详细了解OAuth中使用的以下字段.我将从哪里到达田野.
Consumer Key
Consumer Secret
Token
Token Secret
Timestamp
Nonce
Run Code Online (Sandbox Code Playgroud) 我在YouTube上关注这个教程,它基本上是一个包含你喜欢的音乐的表格,但教程结束了.
它正在使用Angular2,并且一切正常,但是绅士离开它时,它只是在控制台中使用以下代码显示视频的构造函数:
*Playlist.Component.Ts:
export class PlaylistComponent{
onSelect(vid:Video) {
console.log(JSON.stringify(vid)); } }
Run Code Online (Sandbox Code Playgroud)
*Playlist.Component.html:
<table class="table table-hover">
<thead>
<tr>
<td>ID</td>
<td>Title</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr *ngFor="#v of videos" (click)="onSelect(v)">
<td>{{ v.id }}</td>
<td>{{ v.title }}</td>
<td>{{ v.desc }}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
*App.Component.Ts:
import {Component} from 'angular2/core';
import {Config} from './config.service';
import {Video} from './video';
import {PlaylistComponent} from './playlist.component';
@Component({
selector: 'my-app',
templateUrl: 'app/ts/app.component.html',
directives: [PlaylistComponent]
})
export class AppComponent {
mainHeading = Config.MAIN_HEADING;
videos:Array<Video>;
constructor() {
this.videos = [
new Video(1, …Run Code Online (Sandbox Code Playgroud) 即时通讯运行angular2 rc 5一切正常,直到我重新启动我的电脑并再次启动npm,重新启动电脑前一切正常
当我试图再次启动我的项目时,有一个错误说,
node_modules/@angular/platform-browser/index has no exported member 'DomSanitizer'
Run Code Online (Sandbox Code Playgroud)
即时通讯已经尝试重新安装包并从另一个快速启动中复制粘贴@angular文件但工作但仍然失败并出现相同的错误
我想我的@ angular/platform-browser有问题,但我仍然无法弄明白
我正在为练习制作一个Web应用程序,它是一个工作门户.我想为作业创建8位唯一ID,这对最终用户可见.ID可以有数字和字母.模式必须是8位数字,没有连字符或破折号,如XXXXXXXX.
我知道python中有UUID的东西.但它们似乎以特定格式生成id.有没有办法以我所需的格式获取ID?如果没有,有人可以指导我如何去做吗?
我知道有一个类似的线程如何在Python中生成一个唯一的ID?; 但它没有具体回答我的问题.它没有回答我想要实现的目标.
提前致谢.
最近在我们的Angular 2应用程序中,我们添加了一个视频组件来iframe引入外部嵌入式视频.此外,我们通过利用该管道的管道清理这些资源URL DomSanitizer.问题是我们经常,但不一致,收到以下错误,嵌入的视频将无法加载:
网址细分:'null'
样品消毒管道用法:
<iframe [src]="(videoObservable$ | async)?.resourceUrl | sanitizeResourceUrl"></iframe>
Run Code Online (Sandbox Code Playgroud)
管道方法本身:
transform(url: string): SafeResourceUrl {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
Run Code Online (Sandbox Code Playgroud)
记录url参数的值表明最初使用参数值null调用管道,然后在使用值后立即再次调用管道.
我的模拟内存数据库中有youtube链接,我想*来自youtube的这些视频.
let videos: any[] =[
{videoURL: "ZOd5LI4-PcM"},
{videoURL: "d6xQTf8M51A"},
{videoURL :"BIfvIdEJb0U"}
];
Run Code Online (Sandbox Code Playgroud)
像这样.
我使用服务连接我的组件与服务器,现在在HTML中,我已经让v视频.在iframe中,我做到了
<iframe src=v.videoURL></iframe>
Run Code Online (Sandbox Code Playgroud)
但由于它是外部来源,他们告诉我使用Domsanitzer,但我被困在这一部分.
我不知道如何清理应该循环的链接.
constructor( private sanitizer: DomSanitizer) {
this.sanitizer.bypassSecurityTrustResourceUrl('')
Run Code Online (Sandbox Code Playgroud)
< - 我不知道在这里添加什么.
我一直在收到has no attribute DoesNotExist错误.
有什么想法吗?
到目前为止我试过:
try:
current_report = Report.objects.get(account_profile=current_profile)
except Report.DoesNotExist:
print("report doesn't exist")
current_report=None
Run Code Online (Sandbox Code Playgroud)
我的调试显示type object 'Report' has no attribute 'DoesNotExist'
在current_report(etc)行:
我也尝试过:
from django.core.exceptions import ObjectDoesNotExist
...
except Report.ObjectDoesNotExist:
Run Code Online (Sandbox Code Playgroud)
和
try:
Report.objects.get(account_profile=current_profile)
except Report.DoesNotExist:
print("report doesn't exist")
current_report=None
Run Code Online (Sandbox Code Playgroud)
和
try:
Report.objects.get(account_profile=current_profile)
except ObjectDoesNotExist:
print("report doesn't exist")
current_report=None
Run Code Online (Sandbox Code Playgroud)
为什么类型对象'X'没有属性'DoesNotExist'?我正在使用django.
在我的Models.py中,我有:
class Report(models.Model):
account_profile = models.ForeignKey(Profile)
total_visitors = models.CharField(max_length=200, blank=True, null=True)
last_week_visitors = models.CharField(max_length=200, blank=True, null=True)
new_visitors_this_wk = models.CharField(max_length=200, blank=True, null=True)
new_visitors_last_wk = models.CharField(max_length=200, blank=True, null=True) …Run Code Online (Sandbox Code Playgroud) angular ×6
django ×2
api ×1
javascript ×1
oauth ×1
oauth-2.0 ×1
python ×1
python-3.x ×1
rest ×1
sanitize ×1
typescript ×1
uuid ×1
youtube ×1