我不知道为什么app不能正常工作。应用程序在chrome和firefox中工作得很好。即/ edge不显示日期。这是默认的教程角度2应用程序没有修改。我的英语。
import { Component } from '@angular/core'
@Component({
selector: 'my-app',
template: `
<h1>My First Angular App</h1>
<button (click)="showCurrentMonth()">Show Month</button>
<span *ngIf="curentMonth">{{curentMonth}}</span>
<br/>
<button (click)="showCurrentcurentDate()">Show Date</button>
<span *ngIf="curentDate">{{curentDate}}</span>
`
})
export class AppComponent {
splitedDate: string[] = new Date().toLocaleDateString().split(".");
curentMonth: string;
curentDate: Date;
months = [
"January","February","March","April",
"May","June","July","August",
"September","October","November","December"
]
showCurrentMonth() {
// udefined in IE/Edge
this.curentMonth = this.months[parseInt(this.splitedDate[1]) - 1]
}
showCurrentcurentDate() {
var splitedcurrentDate: number[] = new Date()
.toLocaleDateString()
.split(".")
.map(d => parseInt(d, 10))
// invalid Date in IE/Edge
this.curentDate = new Date(splitedcurrentDate[2], splitedcurrentDate[1], splitedcurrentDate[0])
}
}
ts.config
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
的package.json
"dependencies": {
"@angular/common": "~2.0.2",
"@angular/compiler": "~2.0.2",
"@angular/core": "~2.0.2",
"@angular/forms": "~2.0.2",
"@angular/http": "~2.0.2",
"@angular/platform-browser": "~2.0.2",
"@angular/platform-browser-dynamic": "~2.0.2",
"@angular/router": "~3.0.2",
"@angular/upgrade": "~2.0.2",
"angular-in-memory-web-api": "~0.1.5",
"bootstrap": "^3.3.7",
"systemjs": "0.19.39",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.25"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3",
"typings": "^1.4.0",
"canonical-path": "0.0.2",
"http-server": "^0.9.0",
"tslint": "^3.15.1",
"lodash": "^4.16.2",
"jasmine-core": "~2.5.2",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-htmlfile-reporter": "^0.3.4",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^3.3.0",
"rimraf": "^2.5.4"
},
"repository": {}