Reputation: 291
Now i'm using camelcase directive name, like below
<code-input:text></code-input:text> (or)
<code-input-text></code-text-input>
can i use custom directice name and attribute like this,
<code-input:text dirType="text" labelHead="Code" dirName="Code" dirId="code" dirClass="form-control" dirModel="taskCreateForm.code" section-class="col col-3 required"></code-input:text>
if i give like this means , then doesn't render template from directive.because of, i have set every attribute for this is dynamically.
scope : {
dirName : '@',
dirType : '@',
dirModel : '=',
labelHead : '@',
sectionClass : '@',
},
template : [
'<section class="{{sectionClass}}">',
'<label class="label">{{labelHead}}</label>',
'<label class="input">',
'<input type="{{dirType}}" name="{{dirName}}" id="{{dirId}}" class="{{dirClass}}" ng-model="dirModel">',
'</label>',
'</section>'
].join(''),
can anyone give me guidance..is't possible or any issue has occurred because of this.else it's not standard way?
Upvotes: 0
Views: 127
Reputation: 1185
If you created custom directive like
<codeInputText></codeInputText>
You have to use
<code-input-text></code-text-input>
it is better understanding of directive.
Upvotes: 0
Reputation: 48837
From https://docs.angularjs.org/guide/directive#normalization:
The normalization process is as follows:
- Strip
x-
anddata-
from the front of the element/attributes.- Convert the
:
,-
, or_
-delimited name tocamelCase
.
That is to say, code-input-text
and codeInputText
are equivalent and match the codeInputText
directive.
Upvotes: 1