Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use Angular JS attribute in HTML.

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 431
    Comment on it

    Angular is the key to our apps. ng-app directive refers to module and ng-controller directive, which link our controller to our template. In the below example I have created a HTML program with the use of Angular JS attribute.

    Review of these angular attributes:-
    1- The angular attribute ng-repeat, dynamically generate a list of users from our data, and a list of messages.
    2-The ng-submit allows us to call the publish() method from our Javascript code which we will see in a minute.
    3-ng-model using for binding with our data model.

    <body>
    <div class="container" ng-app="PubNubAngularApp" ng-controller="ChatCtrl">
    <br />
    <h4>Online Users</h4>
    <ul>
    <li ng-repeat="user in users">{{user}}</li>
    </ul>
    <br />
    <h4>Chat History ({{messages.length}})</h4>
    <form ng-submit='publish()'>
    <input type="text" ng-model='newMessage' />
    <input type="submit" value="Send" />
    </form>
    <br />
    <div class="well">
    <ul>
    <li ng-repeat="message in messages">{{message}}</li>
    </ul>
    </div>
    </div>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/pubnubAngularApp.js"></script>
    </body>
    

 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: