Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Allow plugin to be activated from scope variable #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions dist/angular-content-editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ angular.module('angular-content-editable')
var directive = {
restrict: 'A',
require: 'ngModel',
scope: { editCallback: '&?', isEditing: '=?', stripReplace: '=?' },
scope: { contentEditable: '<', editCallback: '&?', isEditing: '=?', stripReplace: '=?' },
link: _link
};

Expand Down Expand Up @@ -39,8 +39,15 @@ angular.module('angular-content-editable')
// Get the strip tags option from item scope or global defined
stripReplace = scope.stripReplace || options.stripReplace;

// add editable class
attrs.$addClass(options.editableClass);
// add editable class depending on directive attribute's value
scope.$watch('contentEditable', function (newVal, oldVal) {
if (newVal === true) {
attrs.$addClass(options.editableClass);
} else {
attrs.$removeClass(options.editableClass);
}

});

scope.$watch('isEditing', function(newValue, oldValue) {
if (newValue !== oldValue) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-content-editable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions src/angular-content-editable.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ angular.module('angular-content-editable')
var directive = {
restrict: 'A',
require: 'ngModel',
scope: { editCallback: '&?', isEditing: '=?', stripReplace: '=?' },
scope: { contentEditable: '<', editCallback: '&?', isEditing: '=?', stripReplace: '=?' },
link: _link
};

Expand Down Expand Up @@ -37,8 +37,15 @@ angular.module('angular-content-editable')
// Get the strip tags option from item scope or global defined
stripReplace = scope.stripReplace || options.stripReplace;

// add editable class
attrs.$addClass(options.editableClass);
// add editable class depending on directive attribute's value
scope.$watch('contentEditable', function (newVal, oldVal) {
if (newVal === true) {
attrs.$addClass(options.editableClass);
} else {
attrs.$removeClass(options.editableClass);
}

});

scope.$watch('isEditing', function(newValue, oldValue) {
if (newValue !== oldValue) {
Expand Down