mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
- 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
9 lines
287 B
CoffeeScript
9 lines
287 B
CoffeeScript
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)
|