1

I have a directive in some html something really simple as in:

Date Picker<br/>
<div date-picker-extender></div><p></p>
Hello, David!!!

The directive itself is a quick sample so it looks like this:

app.directive('datePickerExtender', function () {
  return {
     restrict: 'A',
     replace: true,
     template: '<input size="12" type="text" ng-click="showDatePicker()" />',
     controller: function ($scope) {
        $scope.showDatePicker = function () {
            $scope.$root.$broadcast('onShowDatePicker', {});
        };
     }
  }
});

The oddest thing is that if I change the restrict to 'E', nothing below the directive in the markup shows up so I don't even the text 'Hello, David!!!'. Of course, changing the restrict to 'E", I change the markup to this:

<date-picker-extender />.

Can't figure out what the heck is going on.

Ideas?

4
  • 3
    can you try changing it to <date-picker-extender></date-picker-extender>. Commented Aug 3, 2014 at 6:13
  • 1
    Do you get similar results if you do what I did? I've seen so many examples where we shouldn't have to do this. Thanks for your answer though. Commented Aug 3, 2014 at 6:22
  • 1
    There's a good discussion here of why Angular can't really do this: github.com/angular/angular.js/issues/1953 Commented Aug 3, 2014 at 6:24
  • 1
    Okidoke. Very nice article. Thanks much for the information. Commented Aug 3, 2014 at 6:39

1 Answer 1

1

angularjs directives doesnt work with self closing tags: <date-picker-extender />

please checkout this link for more details.

please use syntax: <date-picker-extender></date-picker-extender>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.