javascript - Unable to render templateUrl from custom Directive -
this custom directive
centraapp.directive('counter', function () { return { restrict: 'a', scope: { value: '=value' }, templateurl: '~/scripts/app/shared/directives/counter/partials/counter.html', link: function (scope, element, attributes) { // make sure value attribute not missing. if (angular.isundefined(scope.value)) { throw "missing value attribute on counter directive."; } var min = angular.isundefined(attributes.min) ? null : parseint(attributes.min); var max = angular.isundefined(attributes.max) ? null : parseint(attributes.max); var step = angular.isundefined(attributes.step) ? 1 : parseint(attributes.step); element.addclass('counter-container'); // if 'editable' attribute set, make field editable. scope.readonly = angular.isundefined(attributes.editable) ? true : false; /** * sets value integer. */ var setvalue = function (val) { scope.value = parseint(val); } // set value initially, integer. setvalue(scope.value); /** * decrement value , make sure stay within limits, if defined. */ scope.minus = function () { if (min && (scope.value <= min || scope.value - step <= min) || min === 0 && scope.value < 1) { setvalue(min); return false; } setvalue(scope.value - step); }; /** * increment value , make sure stay within limits, if defined. */ scope.plus = function () { if (max && (scope.value >= max || scope.value + step >= max)) { setvalue(max); return false; } setvalue(scope.value + step); }; /** * triggered when field manually edited user. * can perform validation , make sure enter * correct values within restrictions. */ } } });
and html code
<a href="javascript:;" class="counter-minus" ng-click="minus()">-</a>\ <input type="label" class="counter-field" ng-model="value">\ <a href="javascript:;" class="counter-plus" ng-click="plus()">+</a>
when place html code directly inside template
replacing temlateurl
working fine but, when run using templateurl
, not getting html code, not showing anything, blank page...what should do?
the problem browsers not know ~
character is. asp.net's syntax far know. have put relative path this:
/scripts/app/shared/directives/counter/partials/counter.html
Comments
Post a Comment