EasyUI Forum
May 14, 2024, 11:14:09 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: angular and jquery easyui ng-model  (Read 10299 times)
azizkhani
Newbie
*
Posts: 37


View Profile Email
« on: April 17, 2015, 01:35:02 AM »

one of my big problem in ng-model.
how can set combobox or textbox or combotree  value to ng-model (two way binding)
can u give me an example?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 19, 2015, 07:04:09 PM »

You will have to custom a directive to achieve this functionality. The code below shows a 'easyuiTextbox' directive.
Code:
var app = angular.module('myapp', []);
app.directive('easyuiTextbox', function(){
return {
restrict: 'AE',
require:'ngModel',
link: function(scope, elem, attrs, ngModel){
$(elem).textbox().textbox('textbox').bind('blur', function(){
scope.$apply(function(){
ngModel.$setViewValue($(elem).textbox('getValue'));
})
});
ngModel.$render = function(value){
$(elem).textbox('setValue', ngModel.$viewValue);
}
}
}
})

Usage example:
Code:
<body ng-app="myapp">
<input ng-model="value">
<input easyui-textbox ng-model="value" data-options="required:true"></input>
</body>
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!