I have a function that calls some code using the Jcrop API that takes in some values to set aspect ratio. However, I need those values to come from a data connection for which I'm using Angular. So I need something like this:
<img src="sample.jpg" onclick="setAspectRatio({{valueToSet}});" />
But I get this error when trying to do it that way. If I do it this way:
<img src="sample.jpg" ng-click="setAspectRatio({{valueToSet}});" />
Then valueToSet
actually evaluates, but I can't call it this way as setAspectRatio()
isn't defined in any controller (it's a script on my page itself). This is mainly because it uses Jcrop and I didn't want to mix Jcrop with my Angular controller.
How can I accomplish what I'm trying to do here?
You don't need the {{}} around the variable name. ng-click=setAspectRatio(valueToSet) should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.