I'm trying to set a default value to the select box's options using ng-init in angular js but it isn't working. Here's the code that I have written so far.
var app = angular.module("myApp", [])
app.controller("mainController", ["$scope", function($scope){
$scope.myoptions = "";
$scope.mainList = [
"firstOption",
"secondOption",
"thirdOption"
]
}]);
select{
width:50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<select ng-controller="mainController" ng-options="options as options for options in mainList" ng-model="myoptions" nginit="myoptions=mainList[1]">
</select>
</body>
Please help me with it. Thanks in advance :)
nginittong-init.