mercredi 8 mars 2017

Why is ng-click not working on included checkboxes?

I'm switching contents dynamically in my electron app with angular. Everything was working just fine until I've put my clickable elements, which are checkboxes, into another HTML file, which will be included through ng-include if the given conditions are met. Once included ng-click stops working...

But If I include the checkboxes together with my main content everything is working fine.

I've tested this behavior with other events like ng-change and ng-focus both are working fine as you would expect them to do when they are included.

Even with $compile or $apply the ng-click event wont fire.

All I do is just include the elements like this:

  <div class="col-xs-12" ng-include="appPartials" onload="initInputs(currentSite);">
    <!-- MainContent -->
  </div>

And in my controller like this:

  $scope.appPartials = $scope.paths.viewPart.contentPage2;

Like I said this is only happening with checkboxes together with ng-click, I know that there are other possible ways of handling a checkbox state like checked === true || false.

As mentioned before I've tried:

   $compile(checkBoxElement)($scope);
   $compile(checkBoxElement.parentElement)($scope);
   $compile(checkBoxElement.parentElement.parentElement)($scope);

And also:

   $scope.$apply();

I'm currently using angular 1.6.2.

Regards, Megajin




Aucun commentaire:

Enregistrer un commentaire