Angular attribute attribute value
I want to get the value directly from the attribute directive:
<form cronos-dataset="People as p"> Form Content </form> In my JS, I tried:
app.directive('cronosDataset',[function() { return { restrict: 'A', controller: 'CronosGenericDatasetController', scope: { "cronos-dataset" : '@' } }; }]) .controller("CronosGenericDatasetController",['$scope', function($scope) { alert($scope["cronos-dataset"]); }]); I want to report the string "People as p" , but I get undefined . Is this the right way or should I continue with a different approach?
It is assumed that camelCase is in the scope declaration
app.directive('cronosDataset',[function() { return { restrict: 'A', controller: 'CronosGenericDatasetController', scope: { cronosDataset : '@' } }; }]) Here is a demo to see the different options http://plnkr.co/edit/G6BiGgs4pzNqLW2sSMt7?p=preview