Hello!
I have this worked code:
in controller:
function AppController($log) {
var vm = this;
vm.reports = [
{name: 'Standard', img: 'standard.svg', dialog: reportsStandardDialog},
{name: 'Annual', img: 'annual.svg', dialog: reportsAnnualDialog}
];
function reportsStandardDialog() {
$log.info('reportsStandardDialog');
}
function reportsAnnualDialog() {
$log.info('reportsAnnualDialog');
}
}
in html:
<md-list-item ng-repeat="report in vm.reports" aria-label="{{report.name}}"
ng-click="report.dialog()">
<md-button class="md-icon-button">
<md-icon md-svg-icon="{{'/assets/img/reports/' + report.img}}"></md-icon>
</md-button>
<p ng-bind="report.name"></p>
</md-list-item>
The code is working (i.e. passing function body to ng-click and then running
this body in vm context).
But, is this accepted solution? May be, there are other simple ways? Which is
best practice?
Thank's.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.