admin管理员组

文章数量:1296401

I'm trying to update existing angular 1 application to angular 2. I'm confused, there is nothing about controllers. What is the easiest way to migrate controllers to Angular 2?

I'm trying to update existing angular 1 application to angular 2. I'm confused, there is nothing about controllers. What is the easiest way to migrate controllers to Angular 2?

Share Improve this question asked Oct 11, 2016 at 19:26 Ulad MelekhUlad Melekh 9443 gold badges18 silver badges33 bronze badges 5
  • For what purpose. Don't expect stuff to be translatable 1:1. Angular2 is entirely different from Angular1. Is this about ES5/6 or TypeScript? – Günter Zöchbauer Commented Oct 11, 2016 at 19:28
  • I'm moving to TS side – Ulad Melekh Commented Oct 11, 2016 at 19:30
  • I don't know Angular1 well but I guess you just create a ponent, directive or service class depending on what you try to acplish. – Günter Zöchbauer Commented Oct 11, 2016 at 19:31
  • As pointed in previous ments, angular2 doesn't works like angularjs (or angular1) there is no controller in this version, but I think you can implement an equivalent app just using ponents. Do you have any example of code you want to implement in angular2? – lenilsondc Commented Oct 11, 2016 at 19:37
  • 4 The controller is the ponent .ts file – Eddie Martinez Commented Oct 11, 2016 at 19:37
Add a ment  | 

1 Answer 1

Reset to default 6

Angular2 is built from the ground up. Your best solution is to use Angular2 "Components".

Read more about Components at https://angular.io/api/core/Component

本文标签: javascriptEquivalent of controller in Angular 2Stack Overflow