Last active
August 1, 2017 21:10
-
-
Save Atefnouri/3e407fe000829b9b6a003dc0facbd881 to your computer and use it in GitHub Desktop.
Dynamic Select Angular js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="myApp" ng-controller="MainCtrl"> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> | |
</head> | |
<body> | |
<!-- <div> | |
<div ng-repeat="stuff in stuffs"><h1>{{stuff.name}}</h1> | |
<p>{{stuff.content}}</p></div> | |
</div> --> | |
<label> {{daynamicName}} </label><input type="text" name="{{dynamciModel}}" placeholder="00:00" ><br> | |
<select ng-model="blisterPackTemplateSelected" ng-change="changedValue(blisterPackTemplateSelected)" | |
data-ng-options="blisterPackTemplate as blisterPackTemplate.name for blisterPackTemplate in blisterPackTemplates"> | |
<option value="">Select Account</option> | |
</body> | |
<script> | |
var app = angular.module('myApp', []); | |
app.controller('MainCtrl', function($scope) { | |
$scope.blisterPackTemplates = [{id:1,name:"Math"},{id:2,name:"Informatique"},{id:3,name:"Letter"}]; | |
$scope.changedValue = function(item) { | |
console.log(item.name); | |
switch (item.name) { | |
case 'Math': | |
$scope.daynamicName ="Algebre"; | |
$scope.dynamciModel = "Alg"; | |
break; | |
case 'Informatique': | |
$scope.daynamicName = "TIC"; | |
$scope.dynamciModel = "tic"; | |
break; | |
default: | |
} | |
} | |
$scope.daynamicName = "English" | |
$scope.stuffs = []; | |
$scope.stuffs.push({name: 'English', ng_m: 'EnglishMoy'},{name: 'Gibi', ng_m: 'Asmr'}); | |
$scope.submit = function() { | |
$scope.daynamicName = $scope.stuffs[0].name; | |
$scope.dynamciModel = $scope.stuffs[0].ng_m; | |
} | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment