Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Directives in Angular Js

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 612
    Comment on it

    AngularJS directives are what controls the rendering of the HTML inside an AngularJS application, it also lets you to extends HTML by adding the directives.

    In angular js directives are represented by prefix ng-

    Some of the mostly used directives are as follows:-

    1- ng-app This directive is used to initaialise your application

    <html>
    <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <body>
    <div ng-app="" ng-init="firstName='Ankit'">
    <p>Name: <input type="text" ng-model="firstName"></p>
    <p>You wrote: {{ firstName }}</p>
    
    </div>
    
    </body>
    </html>
    

    The ng-app directive also tells that it is the author of the AngularJS application.

    2- ng-int

    This directive intializes the data of the application

    <div ng-app="" ng-init="firstName='Ankit'">
    <p>Name: <input type="text" ng-model="firstName"></p>
    <p>You wrote: {{ firstName }}</p>
    
    </div>
    

    As above you can see the firstName is initialized.

    3- ng-model

    This directives binds the value of HTML controls (input, select, textarea) to the application data.

    <p>Name: <input type="text" ng-model="firstName"></p>
    

    4- ng-repeat

    This directive is used to repeat the HTML elements

    <div ng-app="" ng-init="names=['Patrick','Akki','Chettri']">
      <ul>
        <li ng-repeat="n in names">
          {{ n}}
    </li>
     </ul>
    </div>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: