2

I'm trying to work out why this doesn't work:

<a class="ng-click: loadSomeDatas();">Click here to load some datas</a>

But this does:

<a ng-click="loadSomeDatas()">Click here to load some datas</a>

Why are you using classes?

Well ng-* attributes don't play nice on some of the clients I have to support, thus rather than shimming them I'd rather just use good ol' safe classes.

2 Answers 2

3

This looks like a documentation error. According to the source code, it can only be used as an attribute. The link function does not use restrict so the default is "attribute only".

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

2 Comments

It's a shame that I have to use the attribute. I might have to consider attaching the event in another way.
@AhmedNuaman remember that you can also use data-ng-click and x-ng-click attributes see here stackoverflow.com/questions/9746916/…
0

Can you try using "data-ng-click"? Angular will still work with data- appended before it's attribute names and this should be valid syntax in older browsers.

<a data-ng-click="loadSomeDatas()" href="#">Click here to load some datas</a>

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.