Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wz-next="function", function is never executed #148

Closed
morissette opened this issue Nov 30, 2015 · 5 comments
Closed

wz-next="function", function is never executed #148

morissette opened this issue Nov 30, 2015 · 5 comments
Labels
Milestone

Comments

@morissette
Copy link

@morissette morissette commented Nov 30, 2015

Description:
I am showing no execution of any function passed to wz-next, either in $scope.function or traditional function func() declarations. Both are simple functions that just log to the console yet nothing is logged.

Angular: 1.4.6

Javascript, controller and module:

(function() {
    var app = angular.module('mydhWizard', ['mgo-angular-wizard']);

    app.controller('WizardCtrl', function($scope, WizardHandler) {
        $scope.finished = function() {
            alert("Wizard finished :)");
        };

        $scope.logStep = function() {
            console.log("Step continued");
        };

        $scope.goBack = function() {
            WizardHandler.wizard().goTo(0);
        };

        $scope.setQuestionaire = function(num) {
            console.log('clicked');
        };
    });


})();

View and directive:

<!-- load directive with wz-next function -->
            <wz-step title="Select Use Case">
                <h1 class="text-center">Select a Use Case</h1>
                <hr>
                <wizard-use-cases></wizard-use-cases>
            </wz-step>


<!-- the following is in the wizardUseCases directive template -->
<button type="button" class="btn btn-block btn-success" wz-next="setQuestionaire(1)">
  Get Started <i class="fa fa-chevron-right"></i>
</button>
@morissette
Copy link
Author

@morissette morissette commented Dec 1, 2015

Additionally it appears that wz-next cancels out ng-click methods

@morissette
Copy link
Author

@morissette morissette commented Dec 1, 2015

I don't like it but I went with the following solution while hoping for a more angularly way of solving my problem:

    var app = angular.module('mydhWizard', ['mgo-angular-wizard']);

    app.controller('WizardCtrl', function($scope, WizardHandler) {
        $scope.finished = function() {
            alert("Wizard finished :)");
        };

        $scope.logStep = function() {
            console.log("Step continued");
        };

        $scope.goBack = function() {
            WizardHandler.wizard().goTo(0);
        };

        $scope.setQuestionaire = function(num) {
            console.log(num);
            WizardHandler.wizard().next();
        };
    });

    app.controller('WizardUseCaseCtrl', function($scope, $rootScope, WizardHandler) {
        var purposes = [
            "develop a new application in the cloud",
            "migrate an existing application to the cloud",
            "create a failover environement for my existing application",
            "create a cloud environment for development and testing",
            "create a cloud storage location for new or existing data",
            "archive data to long term or infrequently-accessed offsite storage",
            "create a disaster recovery environment",
        ];

        $scope.setQuestionaire = function(num, p) {
            $rootScope.wizard_cloud_purpose = "I want to " + purposes[p];
            $rootScope.wizard_questionaire = num;
            WizardHandler.wizard().next();
        };
    });
@jacobscarter
Copy link
Collaborator

@jacobscarter jacobscarter commented Dec 24, 2015

Looking into this

@jacobscarter jacobscarter reopened this Dec 24, 2015
@jacobscarter jacobscarter added the bug label Dec 24, 2015
@jacobscarter jacobscarter added this to the 0.6.0 milestone Dec 24, 2015
@jacobscarter
Copy link
Collaborator

@jacobscarter jacobscarter commented Dec 24, 2015

Also see #113

@jacobscarter
Copy link
Collaborator

@jacobscarter jacobscarter commented Dec 25, 2015

@morissette I just pulled everything down and tested it out. Using this syntax:

<button wz-next="myFunction()">Click Me</button>

myFunction is called. Also adding an ngClick to this button also calls the ngClick method, however it would be very bad practice to do this, especially if timing matters. I would assume that your problem lies in the scope of your <wizard-use-cases></wizard-use-cases> directive but without seeing it I could say for sure.

Closing the issue, will re open if you have further questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.