你能帮忙请转换下面的Angularjs我有价值"20141023"并想转换为AngularJS中的日期,然后显示格式dd/MMM/yyyy非常感谢N.
在 typescript 的 angular2 中,我需要在构造函数中传递字符串参数或偶数参数,如下所示:constructor(_para:string) {} 但生成错误并且调试器不断告诉我:
NoProviderError {message: "No provider for String! (App -> String)", stack: "Error: DI Exception? at NoProviderError.BaseExc…ularjs.org/2.0.0-beta.8/angular2.dev.js:11284 :19)"
如果我删除 _para:string ,它将起作用.... 这是 plnkr 中的 Demoe :
http://plnkr.co/edit/t7serY3L6LtvzYc5xHtL?p=preview
and here is the code :
//our root app component
import {Component} from 'angular2/core'
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
<h2>Hello {{name}}</h2>
</div>
`,
directives: []
})
export class App {
constructor(_para:string) {
this.name = 'Angular2'
}
}
Run Code Online (Sandbox Code Playgroud)