Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Angular 1.0.x compatability - Guard for controller.$setPristine #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
var isPristine = controller.$pristine;
controller.$setViewValue(convertToAngularModel(value));
callback(value);
if (isPristine) {
if (isPristine && controller.$setPristine) {
controller.$setPristine();
}
elm.prev().toggleClass('ng-pristine', controller.$pristine);
Expand Down Expand Up @@ -210,7 +210,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
controller.$setViewValue(
convertToAngularModel(elm.select2('data'))
);
if (isPristine) {
if (isPristine && controller.$setPristine) {
controller.$setPristine();
}
elm.prev().toggleClass('ng-pristine', controller.$pristine);
Expand Down