mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-20 00:37:26 +00:00
Add select2WatchNgModel directive
- Select2 components cannot handle ng-model correctly: they do not update if the ng-model change. Add a directive to watch the ng-model and update the component value
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
angular.module("ofn.admin").directive "select2WatchNgModel", () ->
|
||||
restrict: 'E'
|
||||
scope: true
|
||||
require: "ngModel"
|
||||
link: (scope, element, attrs, ngModel) ->
|
||||
ngModel.$render = () ->
|
||||
newValue = ngModel.$viewValue;
|
||||
element.children(".select2").select2("val", newValue)
|
||||
Reference in New Issue
Block a user