我有一个使用“数字”类型的属性(超时)定义的 Angular 类:
export class EngineSpec {
name: string;
base_url: string;
version: string;
timeout: number;
tls: boolean = false;
user_agent: string;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我 http.post 此类的实例时,该属性作为字符串发送:
{"tls":false,
"name":"local-vm",
"base_url":"http://localhost:2367",
"version":"1.3",
"timeout":"60"
}
Run Code Online (Sandbox Code Playgroud)
任何想法为什么将数字作为 JSON 字符串发送?
我尝试使用 ion-button 在 ionic 4 中实现一个按钮,但没有样式,问题出在哪里,帮助。

我需要帮助,我已经在基于 .Net Core 2.1 的 Angular 上做了一个项目。因此,当我尝试发布 VS 时,返回此错误:
所以,我遵循了这个解决方案:
命令“npm run build -- --prod”退出,出现代码 1 错误但没有成功,我没有找到这个:npm run build -- --prod on my .angular-cli.json
How can i解决这个问题 ?谢谢
日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build',
1 verbose cli '--',
1 verbose cli '--prod' ]
2 info using npm@6.4.1
3 info using node@v10.14.2
4 verbose run-script …Run Code Online (Sandbox Code Playgroud) publish visual-studio-2017 asp.net-core-2.0 angular angular7
如何测试canActivateangular 的函数,该函数返回一个函数,该函数又返回一个boolean值?。
我尝试创建ActivatedrouterSnapshotand 的对象routerStateSnapshot并将其传递给canActivate函数,但这没有帮助。
export class AuthGuard implements CanActivate {
constructor(
private authService: AuthenticationService,
private loginService: LoginService,
private router: Router
) {}
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean>
| boolean {
return this.checkLogin(state.url);
}
checkLogin(url: string): boolean {
if (this.authService.isLoggedIn()) { return true; }
// Store the attempted URL for redirecting
this.loginService.redirectUrl = url;
// Navigate to the login page with extras
this.router.navigate(['/login']);
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
自从 …
我想声明两条 Angular 路线:
/items?id=SOME_ITEM_ID)/items)由于以下不起作用,我想知道如何定义我的路线以满足我的需求?
export const routes: Routes = [
{ path: 'items?id=someItemId', component: ItemComponent },
{ path: 'items', component: AllItemsComponent },
];
Run Code Online (Sandbox Code Playgroud) 我在生产环境中有一个 Web 应用程序。用户每天都在使用它,当我发布更新并且用户返回 Web 应用程序时,他/她会查看 Web 应用程序的旧版本。他需要刷新浏览器才能加载新版本。我怎么解决这个问题?每次发布更新(每周 3-4 次)时,我都无法告诉数百名用户刷新页面。我使用以下内容来构建我的前端应用程序:Angular7 with angular-cli。
我正在寻找一个包含在我的 angular 项目中的包,如下所示:https : //anseki.github.io/leader-line/
我读过将 vanilla javascript 库导入打字稿项目非常麻烦,所以我想知道是否有人知道这个库的等效项作为 angular 的包。我已经在网上搜索过,但到目前为止还没有运气。
我想创建一个角度为7(前端)的Web应用程序,以动态加载不同类型的组件,例如本例 https://angular.io/guide/dynamic-component-loader
但是我不确定使用它是否是个好主意ComponentFactoryResolver。我从没用过,也不知道它是否稳定以及性能如何。
如果您知道替代方案,我希望您对此有意见。我不想用native innerHTML
我正在尝试创建具有动态步骤的自定义和通用向导。这个向导有
这些步骤是动态的。根据某些业务逻辑,可以弹出或删除先前步骤中用户输入的内容
我目前的实现方式如下,
我将仅向您展示我正在使用的部分,以使ComponentFactoryResolver您更容易理解和理解:)
export class WizComponent implements OnInit {
public wizContentItems: WizContentItem[] = undefined;
public currentContentItem: WizContentItem = undefined;
public currentContentItemNumber: number = -1;
public currentWizContentComponent: WizContentComponent = undefined;
private componentRef: any;
@Output() public onStepChanged = new EventEmitter<StepPosition>();
private _position: StepPosition = StepPosition.First;
constructor(private componentFactoryResolver: ComponentFactoryResolver, private viewContainerRef: ViewContainerRef) { }
public ngOnInit() {
}
public onSelectStep(contentItem: WizContentItem) {
console.log("step was clicked");
console.log(contentItem);
if (this.currentContentItem …Run Code Online (Sandbox Code Playgroud) 在角度7中,尝试使用角度材料mat-dialog-content。导入app.module.ts时会出现以下错误:
TypeError:Object(...)不是类似的函数:未捕获TypeError:Object(...)不是platform.es5.js:102上的函数。
package.json
{
"name": "image-cropp",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.15",
"@angular/cdk": "^8.0.1",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/material": "^8.0.1",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"core-js": "^2.5.4",
"ngx-image-cropper": "^1.4.1",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.5",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": …Run Code Online (Sandbox Code Playgroud) angular7 ×10
angular ×9
typescript ×2
angular-cli ×1
angular6 ×1
caching ×1
javascript ×1
json ×1
package ×1
publish ×1
url ×1