Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to use ngModel and innerHTML at the same time #78

Merged
merged 1 commit into from
Feb 28, 2014
Merged

Added ability to use ngModel and innerHTML at the same time #78

merged 1 commit into from
Feb 28, 2014

Conversation

JonathanGawrych
Copy link
Contributor

The current version does not allow you to use ngModel. I moved sanitizing to a factory so it could be used in all directives (so I could use sanitize in textAngular directive). In the case there there is no initial value, the model will be set to the innerHTML. However, if there is a value on the model, it will ignore the current html and use that instead.

@SimeonC
Copy link
Collaborator

SimeonC commented Jan 18, 2014

Thanks, I'll have to have a look at this when I get my laptop on wifi as my mobile makes it look like you're using initial values in the $render function and I can't expand the code to see it all properly.

@@ -346,6 +346,13 @@ textAngular.directive("textAngular", ['$compile', '$window', '$document', '$root
// changes to the model variable from outside the html/text inputs
if(attrs.ngModel){ // if no ngModel, then the only input is from inside text-angular
ngModel.$render = function() {
if(ngModel.$viewValue === undefined && originalContents !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section, shouldn't really be in the $render function (Unless there was a good reason for it being done there?). If you move this logic outside the $render function then it better represents this should only load on first time. Otherwise we would have the problem of the editor resetting to the originalContents in the case of issue #64 whereby the model value is set to undefined and should be blank.
Also it should simplify the code down to:

if(ngModel.$viewValue === undefined && originalContents !== undefined){
    ngModel.$setViewValue(originalContents); // on passing through to taBind it will be sanitised
}

SimeonC pushed a commit that referenced this pull request Jan 20, 2014
SimeonC pushed a commit that referenced this pull request Feb 11, 2014
… of the angular-sanitize tests from their repo.

Including tests and functionality for #79
Added in the $destroy cleanup functions #91
Fixed up using the initial value #78 - we only want it to run ONCE otherwise you can't clear the editor.
Fixed some code up that won't ever get run and also causes some error messages not to show.
@SimeonC
Copy link
Collaborator

SimeonC commented Feb 18, 2014

As I've added this in in the 1.2.0 branch which is nearing release date and It's going to be difficult to merge in this properly, I am going to merge in your work directly prior to merging in the 1.2.0 branch which will overwrite it, thus I don't have to worry about conflicts and you get credit in the repo.

SimeonC pushed a commit that referenced this pull request Feb 28, 2014
@SimeonC SimeonC merged commit b2f4447 into textAngular:master Feb 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants