Skip to content

Instantly share code, notes, and snippets.

@purwandi
Created December 23, 2013 09:01
Show Gist options
  • Save purwandi/8093746 to your computer and use it in GitHub Desktop.
Save purwandi/8093746 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<button ng-controller="MyController" ng-click="testing()" data-id="someCustomValue" data-name="Ketika merdeka">
Press this button
</button>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script>
app = angular.module('app', []);
app.controller('MyController', function ($scope, $attrs) {
$scope.testing = function() {
alert($attrs.name); // console.log($attrs.id); // Prints 'someCustomValue'
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment