Reputation: 5253
I have an image like:
console.log( $scope.image ); // <img alt="hello" class="form" src="demo.jpg">
I want to have the following output (just the text of alt
):
console.log( $scope.image ); // hello
There is an answer for jquery here. But I want to do the same in Angularjs
. Any idea?
Edit: Also $scope.image
contains more html.
Upvotes: 1
Views: 246
Reputation: 113
You can also do the same thing like in your posted answer with jquery using 'angular.element' which give you access to several jquery functionalities set known as jqlite.
var alt = angular.element($scope.image).attr('alt')
EDIT: In case of more html tags inside your $scope.image, do this:
var alt = angular.element($scope.image).find('img').attr('alt')
Upvotes: 3