Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess a div color-picker element through form controller
    primarykey
    data
    text
    <p>I am using this <a href="https://github.com/buberdds/angular-bootstrap-colorpicker" rel="nofollow">library</a> in order to add a color picker feature to my AngularJS app. I would like to allow my client to use a color, which will then appear before him as small square div, with rounded corners(not the hex of the color, as my users are not technological). The problem comes, when I want to allow my users to restore their previous selection, in case they don't like their current one(this info is stored in a service).</p> <p>I would like to access the $pristine, and $dirty attributes of the div that the colorPicker directive is applied on, the problem is that giving a name to a div, is not valid HTML markup.</p> <p>Is there an 'Angular way' to do that(using built in $pristine and $dirty) or would I have to hack my way through this by storing a Boolean flag in my service?.</p> <pre><code>&lt;form name="designForm"&gt; &lt;div class="formLine"&gt; &lt;div class="miniFieldContainerSettings"&gt; Background Color &lt;/div&gt; &lt;div class="mediumFieldContainerSettings"&gt; &lt;div data-colorpicker name="bgColor" class="colorSample" ng-model="model.formData.settings.background_color" data-ng-style="{backgroundColor : model.formData.settings.background_color}"&gt;&lt;!--CANNOT GIVE A NAME ATTRIBUTE TO A DIV--&gt; &lt;/div&gt; &lt;span class="btn btn-link" data-ng-disabled="designForm.bgColor.$pristine" data-ng-click="model.setDefaultColor('bgcolor')"&gt; Restore previous &lt;/span&gt; &lt;span class="btn btn-link" data-ng-click="model.setDefaultColor('bgcolor', true)"&gt; Set default &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload