I\'m trying to achieve something very straightforward:
{
I am having the similar issue for angularjs 1.4. In one controller ng-model value get update. But using the same way on other page it does not work. Following are my codes
Working:
var ctrl = this; ctrl.filters = {}; ctrl.filters.country = $rootScope.lUPro.RM_Country.split(","); $(".country_select2").select2().val(ctrl.filters.country).trigger('change');
Select box is
$comint->CountrySelectBox(array("name"=>"country[]", "class"=>"country_select2 form-control", "id" => "req_country", "ng-model" => "ctrl.filters.country","multiple" =>"multiple"));
Not Working:
var prectrl = this; prectrl.preferenceformdata = {}; var pf = {}; pf.country = $rootScope.lUPro.RM_Country.split(","); prectrl.preferenceformdata = pf; $(".rm_country_select2").select2().val(prectrl.preferenceformdata.country).trigger('change');
Select box:
$comint->CountrySelectBox(array("name"=>"country[]","class"=>"country_select2 form-control","id" => "req_country","ng-model"=>"prectrl.preferenceformdata.country","multiple" =>"multiple"));
So work around i am using to update value in ng-model variable:
$(".country_select2").select2().val(prectrl.preferenceformdata.country) .trigger('change').on("change", function(e){ var values = $(this).val(); $scope.$apply(function(){prectrl.preferenceformdata.country = values;}); });