Skip to content
This repository was archived by the owner on Jan 17, 2022. It is now read-only.

Attributes updating problem #46

Closed
lvarayut opened this issue Feb 5, 2015 · 1 comment
Closed

Attributes updating problem #46

lvarayut opened this issue Feb 5, 2015 · 1 comment

Comments

@lvarayut
Copy link

lvarayut commented Feb 5, 2015

First of all, thanks for the great plugin. I'm trying to apply your plugin with my project for a few hours and having some problems which is when the ng-* attributes got updated inside a ng-click, your plugin always takes old values of the ng-* attributes. For example,

HTML:

   <div class="container-narrow" ng-controller="MyController"
     ng-intro-options="IntroOptions" ng-intro-method="CallMe"
     ng-intro-oncomplete="CompletedEvent" ng-intro-onexit="ExitEvent"
     ng-intro-onchange="ChangeEvent" ng-intro-onbeforechange="BeforeChangeEvent"
     ng-intro-autostart="false">
   <button class="btn btn-large btn-success" ng-click="foo();">Demo</button>

Controller:

  $scope.foo = function() {
    $scope.IntroOptions = {
      steps: [{
        element: document.querySelector('#step1'),
        intro: "This is the first tooltip."
      }, {
        element: document.querySelectorAll('#step2')[0],
        intro: "<strong>You</strong> can also <em>include</em> HTML",
        position: 'right'
      }],
      showStepNumbers: false,
      showBullets: false,
      exitOnOverlayClick: true,
      exitOnEsc: true,
      nextLabel: '<strong>NEXT!</strong>',
      prevLabel: '<span style="color:green">Previous</span>',
      skipLabel: 'Exit',
      doneLabel: 'Thanks'
    };
    $scope.CallMe(); // At this point, your scope.IntroOptions, inside the link function, will be undefined
  };

Please see this problem in action on this Plunkr.

IMHO, I think that you should apply a $watch in all these attributes, for example:

        link: function(scope, element, attrs) {
            scope.$watch('ngIntroOptions', function(old, new){
                if(old !== new)
                    scope.ngIntroOptions = new;
            });
        }
@millerscout
Copy link
Collaborator

i know it's been a while you posted it.

but now we've changed how the directive works, and i don't think it's necessary do that change anymore.

because, now we're using a service to give freedom to developers so they change the behavior as they need, and you may update the intro injecting the ngintroService.

version: 3.1.1 #112,

but if find noticed something that could be improved, i'll be pleased to do it :)

i'll close this issue for the time being, if you still need help tell us, i'll answer Asap

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants