大佬教程收集整理的这篇文章主要介绍了typescript – 从配置文件angular2加载数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我不知道如何在Angular2中创建配置文件.我试图查看如何创建和使用配置文件的链接,但我发现它只用于Java和C#. Angular2中是否存在?
let appProviders = [ http_PROVIDERS,Configurationservice ]; var app = platform(BROWSER_PROVIDERS) .application([BROWSER_APP_PROVIDERS,appProviders]); let service = app.injector.get(ConfigurationservicE); service.getConfiguration().flatMap((configuration) => { var configurationProvider = new Provider('configuration',{ useValue: configuration }); return app.bootstrap(AppComponent,[ configurationProvider ]); }).toPromise();
@Injectable() export class Configurationservice { constructor(private http:http) { } getConfiguration() { return this.http.get('config.json').map(res => res.json()); } }
有关详细信息,请参阅此问题:
以上是大佬教程为你收集整理的typescript – 从配置文件angular2加载数据全部内容,希望文章能够帮你解决typescript – 从配置文件angular2加载数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。