Controllers match components

Components are the backbone of Angular and Ionic applications; you will see that almost everything is a component. You can compare controllers in Angular 1 to components in Angular 4. In controllers we used to define most of our code's logical part. We used to register the controllers with our main module. Now, in a similar way, we define our code in components in Angular 4 and if required we can export that Component class:

    // Angular & Ionic 1angular.module('wedding.controllers', []) .controller('LoginCtrl', function($scope, CategoryService) { // controller function and DI of CategoryService } );// Angular 4 & Ionic 32import {Component} from '@angular/core';import {NavController} from 'ionic-angular';@Component({ ...

Get Hybrid Mobile Development with Ionic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.