While using $mdToast.simple().content(\"some test\")
it is showing the toast with black color. how can I change that color to red, yellow and so, depends on the typ
I first favoured the solution but I don't like setting up a theme in the theme provider just for a toast. So how about this solution:
JS (Coffee)
if error
message = ''
if error.reason is 'Incorrect password'
message = 'Email and password combination is incorrect'
if error.reason is 'User not found'
message = 'No account found with this email address'
$mdToast.show(
templateUrl: 'client/modules/toasts/toastError.html'
hideDelay: 3000
controller: ( $scope ) ->
$scope.message = message
$scope.class = 'error'
$scope.buttonLabel = 'close'
$scope.closeToast = ->
$mdToast.hide()
).then( ( result ) ->
if result is 'ok'
console.log('do action')
)
and then HTML (JADE)
md-toast(ng-class="class")
span(flex) {{message}}
md-button.md-action(ng-click="closeToast()") {{buttonLabel}}
I tried to use the locals
option to pass variables to the controller, but for some reason they are not injected.(https://material.angularjs.org/latest/#/api/material.components.toast/service/$mdToast check list of options under show
function)
Then last the CSS (STYLUS)
md-toast.success
background-color green
md-toast.error
background-color red
Summary: there is on template in this case which you can give custom placeholders which you prefill in your controller. This solution works for me.