我有一个ngSelect,里面有一些选项.
原文链接:https://www.f2er.com/angularjs/141022.html<select data-ng-model="type" data-ng-change="option(type)"> <option data-ng-repeat="type in languages" value="{{type.i18n}}"> {{type.language}} </option> </select>@H_502_2@还有一个控制器
angular.module('navigation',[]) .controller('NavCtrl',['$scope','$translate',function($scope,$translate){ $scope.option = function(type){ console.log(type) //this display the i18n value of languages $translate.use(type); } $scope.languages = [ { language: "English",i18n: "en_EN"},{ language: "Swedish",i18n : "se_SE" } ]; }])@H_502_2@我希望ngSelect有一个默认选项,在我的情况下:“英语”.我试着把它设置为:
$scope.type = $scope.languages[0].language; // English $scope.type = $scope.languages[0]; //The whole darn json object.@H_502_2@请帮忙?