javascript - Creating a simple directive with Angular -


i having simple problem , can't figure out why it's not working.

reviewctrl.html

angular.module('liveapp.review',['liveapp.factory']) .controller('reviewctrl', ['$scope','$http','datafactory','$location',reviewctrl])  .directive("datepicker", function() {     return {         restrict: "e",         template: '<div>i want show in review view</div>'   }       }) 

review.html

<datepicker></datepicker> 

my expectation of code see "i want show in review view" in view corresponding controller. view injected <div ng-view></div> in index.html. have simple example here, reason not working how expect. assume routes set correctly. have idea why might be?

use

 <date-picker>  

in html work.

because angular converts camelcasing snake-casing, datepicker directive needs renamed date-picker in html.


why use camelcasing:


normalization:

angular normalizes element's tag , attribute name determine elements match directives. typically refer directives case-sensitive camelcase normalized name (e.g. ngmodel). however, since html case-insensitive, refer directives in dom lower-case forms, typically using dash-delimited attributes on dom elements (e.g. ng-model).

the normalization process follows:

strip x- , data- front of element/attributes. convert :, -, or _-delimited name camelcase.


see example: http://jsfiddle.net/kevalbhatt18/khz8vxs4/1/


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -