Front End, IT

(2) AngularJs Introduction – ng-directives

  • AngularJS extends HTML with ng-directives.
  • AngularJS directives are HTML attributes with an ng prefix such as (ng-app, ng-model, ng-bind).
  • ng-app: defines an AngularJS application.
  • ng-model: binds the value of HTML controls (input, select, textarea) to application data.
  • ng-bind: binds application data to the HTML view.
  • ng-init:  initializes AngularJS application variables.
1edit
AngularJs ng-directives

The previous code do the following:

  • AngularJS starts automatically when the web page has loaded, as it called in the html file.
  • The ng-app directive tells AngularJS that the <div> element is the owner of an AngularJS application.
  • The ng-model directive binds the value of the input field to the application variable fname.
  • The ng-bind directive binds the innerHTML of the <span> element to the application variable fname.

Review and try it:

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s