Last active
December 27, 2015 03:29
-
-
Save hideaki-t/7260026 to your computer and use it in GitHub Desktop.
to test adding entries into an array for a ng-repeat-ed element
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
<select class="ng-pristine ng-valid" ng-options="e.name for e in entries" ng-model="entry"> | |
<option value="0" selected="selected"> | |
default | |
</option> | |
</select> |
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
<select class="ng-pristine ng-valid" ng-options="e.name for e in entries" ng-model="entry"> | |
<option value="0" selected="selected"> | |
default | |
</option> | |
<option value="1"> | |
B | |
</option> | |
</select> |
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
<select class="ng-pristine ng-valid" ng-options="e.name for e in entries" ng-model="entry"> | |
<option value="?" selected="selected"> | |
</option> | |
<option value="0"> | |
default | |
</option> | |
<option value="1"> | |
B | |
</option> | |
</select> |
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> | |
<title>ng-repeat test</title> | |
<script src="angular.min.js"></script> | |
<script> | |
function c($scope) { | |
var get_default = function () { | |
return {name: "default"}; | |
}; | |
var default_value = get_default(); | |
$scope.entries = [ default_value ]; | |
$scope.entry = default_value; | |
$scope.update = function () { | |
$scope.entries = [ {name: "B"} ]; | |
$scope.entries.unshift(default_value); | |
}; | |
$scope.update2 = function () { | |
$scope.entries = [ {name: "B"} ]; | |
$scope.entries.unshift(get_default()); | |
}; | |
} | |
</script> | |
<div ng-controller="c"> | |
<select ng-model="entry" ng-options="e.name for e in entries"></select> | |
<input type="button" value="load1" ng-click="update()"/> | |
<input type="button" value="load2" ng-click="update2()"/> | |
</div> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment