问题描述:

I am stuck at this issue i have a list of menu item

<md-menu-item ng-value="menuItem.value" ng-repeat="menuItem in filtermenu.menuItems" ng-click="activeFilterCtrl.selectedfilter(menuItem)" translate>

<md-button>

{{ menuItem.name }}

</md-button>

</md-menu-item>

Following is the code i want to display the value of selected menu item on a button or on a label which should be displayed after selection of menu item.

Please help me resolve the issue

网友答案:

In your code you call the selectedFilter(menuItem) function. You can then add this in your function:

$scope.selectedFilter = function(menuItem){
// your code here
$scope.myLabel = menuItem.name;
}

And in your HTML:

<md-button>
    {{myLabel}}
</md-button>
网友答案:

Probably the md-button directive creates its own scope and therefore menuItem is not present at this scope. Try $parent.menuItem to access the parent scope which should be the scope of ng-repeat.

相关阅读:
Top