我使用下面的代码在angular5中运行时添加或更新元标记
import { Title ,Meta} from '@angular/platform-browser';
constructor( private meta:Meta)
{
this.meta.addTags([
{name: 'description', content: 'How to use Angular 4 meta
service'},
{name: 'author', content: 'talkingdotnet'},
{name: 'keywords', content: 'Angular, Meta Service'}
]);
this.meta.updateTag({ name: 'description', content: 'Angular 4 meta service'
});
}
Run Code Online (Sandbox Code Playgroud)
在appmodule中导入的元服务
但它不起作用(不在我的页面源中).任何人都可以帮助我
谢谢
我正在尝试在线购买角度5模板,所以我只想确认角度版本.我查了一下Angular这个问题: -
但是在这个问题中,app版本显示在下面的图片中,该图片是从开发工具中捕获的,
ng-version is in app tag.
Run Code Online (Sandbox Code Playgroud)
但在我试图购买的模板中有以下结构.
ng-version is in body tag.
Run Code Online (Sandbox Code Playgroud)
所以,只是为了再次确认我刚刚安装了Angular 5.这里在新安装的应用程序中显示,
ng-version is in app-root.
该模板有其他文件,如,
<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="polyfills.bundle.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>
<script type="text/javascript" src="main.bundle.js">
Run Code Online (Sandbox Code Playgroud)
我也试过,angular.version但它对我不起作用.
因此,确认他们使用的是Angular App而不是其他东西,但我对它的Angular-2,4或5感到困惑.
还有其他方面我们可以确定它正在运行哪个版本?
我正在开发一个 Angular 5 应用程序。我必须从我的后端应用程序下载一个文件,为此我只需调用如下函数:
public executeDownload(id: string): Observable<Blob> {
return this.http.get(this.replaceUrl('app/download', denunciaId), {responseType: 'blob'}).map(result => {
return result;
});
}
Run Code Online (Sandbox Code Playgroud)
并调用我刚刚调用的下载服务:
public onDownload() {
this.downloadService.executeDownload(this.id).subscribe(res => {
saveAs(res, 'file.pdf');
}, (error) => {
console.log('TODO', error);
// error.error is a Blob but i need to manage it as RemoteError[]
});
}
Run Code Online (Sandbox Code Playgroud)
当后端应用程序处于特定状态时,它不会返回 Blob,而是返回一个HttpErrorResponse在其error字段中包含RemoteError 数组的对象。RemoteError 是我编写的用于管理远程错误的接口。
在 catch 函数中,error.error 是一个 Blob。如何将 Blob 属性转换为RemoteError[]?
提前致谢。
ngAfterViewInit(){
Observable.interval(3000).timeInterval().subscribe()=>{};
}
Run Code Online (Sandbox Code Playgroud)
尝试调用Observable.interval()方法时,它会抛出一个编译器错误"类型observable中不存在属性区间".
编辑
import { Observable } from 'rxjs/Observable';
Run Code Online (Sandbox Code Playgroud)
请注意,import语句已包含在内
我有一个primeng turbo-table组件.我需要在桌面上应用多个过滤器.
从父母那里我
myTable.doFilter(first_values);
myTable.doFilter(second_values);一个接一个地 打电话
在子(turbo-table)组件上,实际过滤器的应用类似于
doFilter(...filter_values...){
this.pTable.filter(...filter_values...);
}
问题是第二个过滤器在第一个过滤器完成之前应用并导致意外结果.
上一次过滤完成后,如何调用过滤器.过滤器完成后会发出一个事件但我无法找到一种方法来利用它.
Parent.ts
fetchList(searchData) {
this.ratesTable.reset();
this.ratesDataSource = [];
this.programService.fetchList(searchData)
.then(
(response) => {
this.ratesDataSource = response.rates;
this.doTermFilter();
this.doLoanFilter();
})
.catch((error) => {
console.error("from ts" + error);
});
}
doTermFilter(){
this.doFilter({ filterValue: _termFilters, columnField: "COL1", filterMethod: "in" });
}
doLoanFilter(){
this.doFilter({ filterValue: _loanFilters, columnField: "COL7", filterMethod: "in" });
}
Run Code Online (Sandbox Code Playgroud)
child.ts(涡轮表)
doFilter(doFilterInput: { filterValue: any[], columnField: any, filterMethod: any }) {
this.pTable.filter(doFilterInput.filterValue, doFilterInput.columnField, doFilterInput.filterMethod);
}
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢.谢谢
在我的应用程序中,我有一个类别页面,其中包含指向各种产品列表页面的链接.如果结果是当您到达产品列表页面时只有一个产品,那么它会自动导航到该产品详细信息页面.我想要的是删除历史记录中的产品列表页面路径,以便当用户在产品详细信息页面上并点击后退按钮时,他们将转到类别页面而不是产品列表页面,因为这只会重定向它们到详细页面.
当我运行build -prod时,我收到以下警告.
Warning: Can't resolve all parameters for UsersPermissionsService in C:/SourceControl/Test.Client/src/app/shared/users/users-permissions.service.ts: (?, ?, ?). This will become an error in Angular v5.x
Warning: Can't resolve all parameters for UsersPermissionsService in C:/SourceControl/Test.Client/src/app/shared/users/users-permissions.service.ts: (?, ?, ?). This will become an error in Angular v5.x
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
import { Injectable } from '@angular/core';
@Injectable()
export class UsersPermissionsService {
public USERS_CREATE_PERMISSION: string = '';
public USERS_UPDATE_PERMISSION: string = '';
public USERS_DELETE_PERMISSION: string = '';
constructor(public UsersCreatePermission: string,
public UsersUpdatePermission: string,
public UsersDeletePermission: string) {
this.USERS_CREATE_PERMISSION …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序上添加Angular Material Paginator.
在模块中添加了MatPaginatorModule.
<mat-paginator #paginator
[length]="100"
[pageSize]="10"
[pageSizeOptions]="[5, 10, 25, 100]">
</mat-paginator>
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误:
未捕获错误:模板解析错误:
无法绑定到'length',因为它不是'mat-paginator'的已知属性.
mat-paginator是Angular组件并且它有length输入,则验证它是否是此模块的一部分.mat-paginator是一个Web组件,然后添加CUSTOM_ELEMENTS_SCHEMA到@NgModule.schemas该组件来抑制此消息.
也许我错过了什么?
"@angular/animations": "^5.0.1",
"@angular/cdk": "^5.0.0-rc0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.0.0-rc0",
Run Code Online (Sandbox Code Playgroud) pagination angular-material2 angular angular5 angular-material-paginator
我正在使用带有Reactive表单的Angular 5,并且需要使用valueChanges来动态地禁用所需的验证
组件类:
export class UserEditor implements OnInit {
public userForm: FormGroup;
userName: FormControl;
firstName: FormControl;
lastName: FormControl;
email: FormControl;
loginTypeId: FormControl;
password: FormControl;
confirmPassword: FormControl;
...
ngOnInit() {
this.createFormControls();
this.createForm();
this.userForm.get('loginTypeId').valueChanges.subscribe(
(loginTypeId: string) => {
console.log("log this!");
if (loginTypeId === "1") {
console.log("disable validators");
Validators.pattern('^[0-9]{5}(?:-[0-9]{4})?$')]);
this.userForm.get('password').setValidators([]);
this.userForm.get('confirmPassword').setValidators([]);
} else if (loginTypeId === '2') {
console.log("enable validators");
this.userForm.get('password').setValidators([Validators.required, Validators.minLength(8)]);
this.userForm.get('confirmPassword').setValidators([Validators.required, Validators.minLength(8)]);
}
this.userForm.get('loginTypeId').updateValueAndValidity();
}
)
}
createFormControls() {
this.userName = new FormControl('', [
Validators.required,
Validators.minLength(4)
]);
this.firstName = new FormControl('', …Run Code Online (Sandbox Code Playgroud) 我正在将购买的第三方模板转换为Angular 5应用程序,并且遇到了错误.我对Angular 5很新(但我知道AngularJS很好)并且不明白它试图告诉我什么?它似乎与显示/隐藏顶部导航栏的按钮有关.
错误消息(来自浏览器):
Error: Template parse errors:
No provider for ControlContainer ("imalize-styl-2 btn btn-primary " (click)="toggleNavigation()"><i class="fa fa-bars"></i> </a>
[ERROR ->]<form role="search" class="navbar-form-custom" method="post" action="#">
<div class="form-gro"): ng:///AppModule/TopNavigationNavbarComponent.html@4:6
Run Code Online (Sandbox Code Playgroud)
component.html:
<div class="row border-bottom">
<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<a class="minimalize-styl-2 btn btn-primary " (click)="toggleNavigation()"><i class="fa fa-bars"></i> </a>
<form role="search" class="navbar-form-custom" method="post" action="#">
<div class="form-group">
<input type="text" placeholder="Search for something..." class="form-control" name="top-search" id="top-search">
</div>
</form>
</div>
<ul class="nav navbar-top-links navbar-right">
<li>
<a href="#">
<i class="fa fa-sign-out"></i> Log out …Run Code Online (Sandbox Code Playgroud) angular5 ×10
angular ×9
typescript ×2
blob ×1
http ×1
javascript ×1
pagination ×1
primeng ×1
rxjs ×1