我对Typescript很新.tsconfig.json中的Target表示什么?
{
"compilerOptions":
{
"sourceMap": true,
"target": "es5",
"module": "commonjs",
"jsx": "react",
"moduleResolution": "classic",
"lib": [ "es2015", "dom", "es2017" ]
}
}
Run Code Online (Sandbox Code Playgroud) 我正在将React代码转换为typescript,tsconfig中的目标是es5.
在IE 11中运行我收到错误"Promise is undefined"
我知道我需要填充,但如何?
我没有使用巴别塔.
以下是我的Webpack.config
var webpack = require("webpack");
var Promise = require('es6-promise').Promise;
var paths = require('./config/paths');
var HtmlWebpackPlugin = require('html-webpack-plugin');
//var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var AureliaWebpackPlugin = require('aurelia-webpack-plugin');
var publicPath = '/';
var publicUrl = '';
module.exports = {
entry: {
app: [
'core-js/fn/promise',
'./Generated Files/app.js'
],
vendor: paths.vendorPath,
},
output: {
path:__dirname + "/dist",
filename: 'bundle.js',
publicPath: publicPath
},
devtool: '#source-map',
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
module: {
loaders: [ …
Run Code Online (Sandbox Code Playgroud) 如何在有角度的readonly中进行formControl
我知道我可以用html这样做
<input type="text" formControlName="xyz" readonly />
Run Code Online (Sandbox Code Playgroud)
如何从JS代码而不是html,即以模型驱动的方式
我有一些陈述
<ng-template [ngIf]="xyz== 1">First</ng-template>
<ng-template [ngIf]="pqr == 2">Second</ng-template>
<ng-template [ngIf]="abc == 3">Third</ng-template>
Run Code Online (Sandbox Code Playgroud)
上述陈述中的多个条件都可以成立.
但我想要的是,首先检查第一个声明是否为真,然后显示并保留其余部分
如果为false,则检查第二个,依此类推
怎么实现这个?
我有一个自定义的模型驱动表单验证器来验证最大文本长度
export function maxTextLength(length: string) {
return function (control: FormControl) {
const maxLenghtAllowed: number = +length;
let value: string = control.value;
if (value !== '' && value != null) {
value = value.trim();
}
if (value != null && value.length > maxLenghtAllowed) {
return { maxTextLength: true };
}else {
return null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何编写单元测试用例形成这个?
unit-testing custom-validators karma-jasmine angular angular-reactive-forms
我有这种反应性角形结构
myForm: FormGroup;
Personal: FormGroup;
FIRST_NAME: FormControl;
LAST_NAME: FormControl;
ngOnInit(): void {
this.createFormControls();
this.createForm();
}
createFormControls() {
this.FIRST_NAME = new FormControl('', [Validators.required]);
this.LAST_NAME = new FormControl('', [Validators.required]);
}
createForm(): void {
this.myForm = this.fb.group({
Personal: this.fb.group({
FIRST_NAME: this.FIRST_NAME,
LAST_NAME: this.LAST_NAME,
})
})
}
Run Code Online (Sandbox Code Playgroud)
如果我做
this.FIRST_NAME.disable();
Run Code Online (Sandbox Code Playgroud)
它禁用FormControl
如何禁用Personal FormGroup中的所有FormControls
我如何在"tsx"中包含"css"文件以及如何使用它?即如何渲染静态文件?
import * as React from "react";
import { Header } from "./header";
//import "./home.css";
export class Home extends React.Component<{}, {}> {
render() {
return (
<div id="page-top" className="landing-page">
<Header />
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用角度材料2 Date-Picker组件
它理解的唯一字符串输入是ISO日期格式
防爆."2017-11-13T10:39:28.300Z"
但我想用语言环境日期值修补我的表单控件
防爆."11/13/2017,下午4:09:46"
因此它输出后面的格式甚至期望这种格式.
我怎样才能做到这一点?有没有办法不使用ISO但自定义格式?
一些想法:
我应该写customDateAdaptor吗?
更新:
https://stackblitz.com/edit/angular-material-moment-adapter-example-bqvm2f
我试图通过扩展nativeDateAdaptor来实现自定义dateAdaptor
angular ×5
javascript ×3
typescript ×3
css ×1
datepicker ×1
ecmascript-5 ×1
formgroups ×1
momentjs ×1
polyfills ×1
reactjs ×1
transpiler ×1
tsconfig ×1
unit-testing ×1