Reputation: 259
Not sure if the way i phrased my question makes sense, sorry if it doesn't. Basically, what I want to ask is, is it possible to retrieve value from href into controller. Example,
I have 2 href
<a href="" ng-model="a">Download1</a>
<a href="" ng-model="b">Download2</a>
So, when download1 is clicked, it will store 'a' into a variable in my controller. Is that possible?
Upvotes: 2
Views: 157
Reputation: 6728
You can use ng-click
for that.
<a href="" ng-click="download('a')">Download1</a>
So, in your Controller you must have the download function like this.
$scope.download = function(value){
console.log(value)
}
and you do the same thing for b only in the html part because you can use the same function, which is download().
<a href="" ng-click="download('b')">Download2</a>
Now if you click Download1 you will get
a
and when you click Download2 you will get
b
Upvotes: 1