Angular2模板具有安全的运算符(?.),但在component.ts(typescript 2.0)中.安全导航操作员(!)无法正常工作.
例:
这个TypeScript
if (a!.b!.c) { }
Run Code Online (Sandbox Code Playgroud)
编译到这个JavaScript
if (a.b.c) { }
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我得到以下错误:
无法读取未定义的属性'b'
还有其他选择:
if (a && a.b && a.b.c) { }
Run Code Online (Sandbox Code Playgroud)
?
我在我的项目中安装了interact.js angular2,但我不知道如何使用文档中描述的方法。
我的导入如下
import * as _ from 'interact';
Run Code Online (Sandbox Code Playgroud)
Angular2 中是否有可能提供完整的 interact.js 服务?如何创建对拖放的支持?
DT https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/interact.js
在我的angular2应用程序中,我有js文件"connection.conf.js"与var:
var appTypeConf = "example-app";
Run Code Online (Sandbox Code Playgroud)
Component使用"connection.conf.js"中的变量:
declare var appTypeConf: string;
export class Component {
public appType = appTypeConf;
}
Run Code Online (Sandbox Code Playgroud)
它在我的应用程序中核心工作,但当我用业力测试应用程序时,我收到一个错误:
ReferenceError: Can't find variable: appTypeConf (line 9)
Run Code Online (Sandbox Code Playgroud)
如何在组件规范文件中核心声明一个变量?
更新到rc3后,ngFormModel无法正常工作
我的HTML:
<form [ngFormModel]="form">
<select ngControl="syncTime" name="syncTime" [disabled]="!sync" class="form- control">
</select>
</form>
Run Code Online (Sandbox Code Playgroud)
我的.ts
constructor(private fb: FormBuilder) {
this.form = this.fb.group({
syncTime: this.syncTime
});
Run Code Online (Sandbox Code Playgroud) 更新到Angular2 rc2和Angular2 rc3后,我有错误
"'路由器'类型中不存在"属性'urlTree'"
我的功能
isRouteActive(routePath) {
return this.router.urlTree.contains(this.router.createUrlTree(routePath));
}
Run Code Online (Sandbox Code Playgroud)
如何在angular2 rc3中获得活动链接?
在默认情况下,'if'一行语句是两个块,对于true和false:
variable ? true block : false block;
Run Code Online (Sandbox Code Playgroud)
如何用一个块声明'if'?
我期待这样的事情:
variable ? true block;
Run Code Online (Sandbox Code Playgroud) angular ×4
typescript ×3
formbuilder ×1
if-statement ×1
interact.js ×1
javascript ×1
routes ×1
unit-testing ×1