0

I have an AngularJS link that is not firing, so that when the item is clicked, nothing happens. The click event only has one line of code, that works in other parts of the website:

// Load Add Job Template
dashboard.loadAddJob = function() {
    dashboard.global.template = "templates/AddJob.html";
}

And the click element is a simple link:

<a ng-click="loadAddJob()">
    <i class="fa fa-plus-square-o"></i><br />
    Add <br />Job
</a>

Everything else works on the page so I know the controller and app are both declared correctly. Is there something I'm missing?

3
  • 1
    what is dashboard? Is dashboard your this instance(controller As syntax)? Commented Jun 26, 2017 at 9:12
  • can u share more code on plunker? Commented Jun 26, 2017 at 9:13
  • 3
    You should know by now to provide a minimal reproducible example Commented Jun 26, 2017 at 9:15

1 Answer 1

3

your function should be,

$scope.loadAddJob = function() {
    dashboard.global.template = "templates/AddJob.html";
}

if you are using Controller as syntax, the HTML should be changed to,

<a ng-click="dashboard.loadAddJob()">
Sign up to request clarification or add additional context in comments.

3 Comments

Or they could be using the controllerAs syntax in which case they'd need to change ng-click="dashboard.loadAddJob()"
then it should be <a ng-click="dashboard.loadAddJob()">
I've missed it out but I have a line in my code that renames the $scope for ease var dashboard = this - putting dashboard at the start of the function in the ng-click did fix the issue though, thanks!

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.