To access element attributes from a controller, enter $attrs in your controller function:
HTML
<div test="hello world" ng-controller="ctrl"> </div>
Script
app.controller('ctrl', function($attrs) { alert($attrs.test);
In your example, if you want to get data-project-id:
$attrs.projectId
Or if you want to get id:
$attrs.id
Demo:
var app = angular.module('app',[]); app.controller('ctrl', function($attrs) { alert($attrs.test); });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="app" ng-controller="ctrl" test="hello world"> </div>
source share