I'm using angualr-material and want to pass a parameter to $mdToast.show()
inside controller, I checked out there is a scope in the function but I don't know how to code it, I tried lots of expressions, but not working out, please help me, thanks a lot!
Here is my code:
Js:
var test='test for angular';
$mdToast.show({
templateUrl: 'TemplateView/CustomToast/warning.html',
controller: 'WarningToastCtrl',
scope:test
});
angular.module('app')
.controller('WarningToastCtrl', ['$scope', function ($scope) {
$scope.value=test;
}]);
Html:
<md-toast class="warning-toast">
<span flex>{{value}}</span>
</md-toast>
Q: How to show the value into test for angular?
Ok, I just found out there is a locals to use:
$mdToast.show({
templateUrl: 'TemplateView/CustomToast/warning.html',
controller: 'WarningToastCtrl',
locals:{parm:test}
});
angular.module('app')
.controller('WarningToastCtrl', ['$scope', 'parm', function ($scope, parm) {
$scope.showValue = parm;
}]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With