mobiscroll在angularjs中加载页面时设置默认值

时间:2015-12-23 04:19:56

标签: angularjs mobiscroll

我正在使用jquery mobiscroll for angularjs。每件事都按预期工作,但我想设置从服务器获取的值。

我的指示

.directive('mobiSelect', function() {
  return {
    restrict: 'A',
    scope: {
      ngModel: "="
    },

    link: function($scope, element, attrs) {      
      return $(element).mobiscroll().select({
        theme: 'android-ics light',
        display: 'modal',
        minWidth: 500,   
        headerText: 'Select Option'
      });    
    }
  };

});

控制器

$scope.ptitle = [
  {code: 'Mr', description: 'Mr'}, 
  {code: 'Mrs', description: 'Mrs'}
]; 
//this value i received from server
$scope.personalDetails.title = 'Mr';

模板

<select name="title" id="title" ng-options="option.code as option.description for option in ptitle" data-ng-model="personalDetails.title" ng-required="true" mobi-select=true>  
</select> 

一旦打开滚动条,模型值突出显示,但我想以下列方式在输入字段中自动设置值: enter image description here

0 个答案:

没有答案