Skip to content

Upgrade from Angular 1.x to 2

Victor Dias edited this page Dec 12, 2016 · 5 revisions

Upgrade Angular 1.x to Angular 2

Using Component Directives

To be Angular 2 compatible, an Angular 1 component directive should configure these attributes:

  • restrict: 'E'. Components are usually used as elements.
  • scope: {} - an isolate scope. In Angular 2, components are always isolated from their surroundings, and we should do this in Angular 1 too.
  • bindToController: {}. Component inputs and outputs should be bound to the controller instead of using the $scope.
  • controller and controllerAs. Components have their own controllers. template or templateUrl. Components have their own templates.

Component directives may also use the following attributes:

  • transclude: true, if the component needs to transclude content from elsewhere.
  • require, if the component needs to communicate with some parent component's controller.

Using Webpack

As partes confusas do Webpack