How to restrict textbox values in angularJS

In this article i show you how to get textbox value in angulaJS. First we need to add angularJS reference
in html page
Step1:- add angularJS reference in html page
    <script src="Scripts/angular.js"></script>
    <script src="Scripts/Script1.js"></script>
Script1.js is the javascript file for declaring module and controller

/// <reference path="angular.min.js" />
var app = angular.module("myapp",[])
    .controller("mycontroller", function ($scope)
    {
})
add reference to the javascriptfile
step2:-Add html page.In angularJS we have two directives ng-mimilenth ang ng-maxlenth for restricting textbox values.We are using expressions for getting textbox value.Expressions are declared by using bracess
    <div ng-app="myapp">
        <div ng-controller="mycontroller">
            <input type="text" ng-model="name" ng-maxlength="12" ng-minlength="5"  />
            <br />
            <br />
            {{name}}
        </div>
    </div>

No comments:

Post a Comment