When I use ng-click, I am able to retrieve the html element by id. However, when I use ng-init, I only get null. Please take a look at my codepen here.
HTML Code:
<script type="text/javascript">
var memId = "bb7de28f-0f89-4f14-8575-d494203acec7";
</script>
<div ng-app="myapp" ng-controller="MainCtrl" ng-init="getMember(memId)">
<span id="audio-{{memId}}">
Your member ID: {{memId}}
</span>
<span ng-click="getMember(memId)"> Click me <span>
</div>
Controller Code:
var app = angular.module('myapp', []);
app.controller('MainCtrl', ['$scope', '$window', function($scope, $window) {
$scope.memId = $window.memId;
$scope.getMember = function(id) {
console.log(id);
var voice = document.getElementById('audio-' + id);
console.log(voice);
};
}]);