简体   繁体   中英

When I am using angular-cli, how do I implement the controller?

What I want to do: simple event, when user clicks a button, "hello world" is output to console or screen

What I am having trouble with: I understand what a controller does, but what I don't understand is how to create a controller, link that file(if its a file) to my view. Do I just link the script src of the file? do i import it to component.ts?..this is where i am confused.

In angular component.ts file work as a controller. The component is associated with view. If you are mapping from AngularJS to angular the component.ts is nothing but the controller of your view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM