Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy AngularJS Tutorial</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> </head> <body> <form ng-app="myApp" name="form" ng-controller="requiredCtrl"> <h3>ng-required Directive in AngularJS Tutorial</h3> Toggle required: <input type="checkbox" ng-model="required"><br> Enter the text: <input type="text" ng-model="model" name="input" ng-required="required" /><br> <p>form.input.$error.required ={{form.input.$error.required}}</p> <p> model = {{model}}</p> </form> <script> var app=angular.module('myApp', []); app.controller('requiredCtrl', ['$scope', function($scope) { $scope.required = true; }]); </script> </body> </html>
www.wikitechy.com © Copyright 2016. All Rights Reserved.