Posts

Showing posts from January, 2018

Using Controllers in AngularJS

Image
The controllers primary purpose is to control the view model contained within the Angular scope. Controllers are used in AngularJS to: Set the initial state of Scope variables, which are then made available for the View to consume and interact with Add behavior to the Scope by two-way binding variables and declaring Scope functions Set up communications to and from the view and Model objects such as Services, brought in through Dependency Injection Angular invokes the controller with a $scope object. Any objects (or primitives) assigned to the scope become model properties. The role of controllers in Angular is to expose data to our view via $scope, and to add functions to $scope that contain business logic that enhances view behavior.  A controller should contain only the business logic needed for a single view; presentation logic should remain within views and directives. Controllers are created by registering with an existing Angular Module. var app = angular

Getting Started with Angular

Image
In the phase of beginning of my post, I’d like to give a brief introduction about Angular. Angular is an open source web framework for JavaScript applications. Nowadays Angular has become an outstanding web development framework because of the following reasons.   Provides improved application design architecture Promotes code  re usability Consists of easy to remove components Employs two way data binding Angular contains the following core types of objects and components. Modules Controllers Services   Directives These core components can be injected into each other using Dependency Injection (DI) mechanism built in Angular. DI is a software design pattern that assigns dependencies to components instead of hard coding them within the component itself. Angular uses a feature called directives that allow to write HTML code, which then builds the HTML of the application instead of using templates to generate the user interface. The adoption of two-way data bindi