I'm trying to get the value of a data-attributes element in angular. I have my controller like this:
controller code:
(function() {
'use strict';
var app = angular.module('myApp');
app.controller('globalCtrl', function ($scope) {
var dataPreview = document.getElementsByClassName('element');
$scope.item = {
name: dataPreview.getAttribute("data-branch"),
shortname: dataPreview.getAttribute("data-short-name")
};
});
}(window, window.angular));
But the console returns the following error:
dataPreview.getAttribute is not a function
I'm lost trying to find a solution to this error, can someone tell me what's wrong with my code