Angular 2如何将自定义功能导入组件和服务 [英] angular 2 how to import custom function to component and service
本文介绍了Angular 2如何将自定义功能导入组件和服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的功能
myHelperNumber.js
function myLittleBoy(){
console.log('I see you)
}
如何在User.js组件或userSevicer.js服务中使用此功能?
How to use this function in User.js component or userSevicer.js service?
推荐答案
myHelperFunction.ts
export function myLittleBoy(){
console.log('I see you)
}
RegisterComponent.ts
import {myLittleBoy} from 'path to myhelperfunction.ts'
这篇关于Angular 2如何将自定义功能导入组件和服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文