0

I'm using text-angular to save html-based content into database and i want to save checkboxes with the checked attribute on them. I've tried to use the input field like below but text-angular doesnt render checkboxes with checked attribute. Is there any way to do this without doing pure css checkboxes?

<input type="checkbox" checked>

EDIT: The code I am using:

<text-angular data-ng-model="example_content" placeholder="Content..." 
              rows="5">

And inside the textarea of the text-angular directive, I am trying to insert the input from above but it renders without checked attribute

tanmay
  • 7,761
  • 2
  • 19
  • 38
  • provide full code in which you have problem – Gaurav Kumar Singh Mar 22 '17 at 10:49
  • @Gaurav it's just the text-angular directive. and inside the textarea of the directive i am inserting the input from the post but it doesnt render it checked. it renders the checkbox but unchecked. I edited the main post – Ionuț Zamfir Mar 22 '17 at 10:54

2 Answers2

0

You can achieve by using ng-click

   <input type='checkbox' ng-click='onsaveValue()' ng-model="saveValue">
Venugopal
  • 1
  • 1
0

I looked up in text-angular's sanitizer library textAngular-sanitize.js to find out that the checked attribute isn't part of their htmlAttrs attribute map.

Hence, the only option we're left with is to override the sanitizer JS file with the edit. Moreover, you can add other attributes/tags if you want (Do consider vulnerabilities though!)

Here's the working example plunker forked from official text-Angular plunker. Notice the ta-sanitize.js included in plunker which is modified version of their textAngular-sanitize.js

Hope this helps!

tanmay
  • 7,761
  • 2
  • 19
  • 38