Ng-Options-5

 

ng-options generate list of names using array of object "HideShow".Selected option will hide or show the checkbox based on the value of variable isHide with ng-model directive.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="Example"> <div ng-controller="ExampleController" ng-init="StudentId=1"> Hide/Show: <select ng-model="isHide" ng-options="IsShow.isHide as IsShow.name for IsShow in HideShow"></select><br /> <span ng-hide="isHide"> Hide Me <input type="checkbox" ng-model="isHide" /></span> </div> <script> var app = angular.module("Example", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.HideShow = [{ name: 'Hide', isHide: true, }, { name: 'Show', isHide: false }]; }]); </script> </body> </html>
Output