I have this rather simple code to open a dialog once the user click on a button, on my controller I have the following code, not far from the sample one found on the documentation:
$scope.confirmDelete = function() {
$mdDialog.show(
$mdDialog.alert()
.title('Confirm delete?')
.clickOutsideToClose(true)
.textContent('Hello world')
.ok('Yes')
.targetEvent(originatorEv)
);
originatorEv = null;
};
And my browser log this error
Error: $mdDialog.alert(...).title(...).clickOutsideToClose(...).textContent is not a function
But if I remove the textContent function it works perfectly, any idea?
What Angular Material Version are you using?
Latest version, just downloaded yesterday
I have the same issue with Angular Material:
$scope.showSaveDialog = function (ev) {
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('#tabsaver2')))
.clickOutsideToClose(true)
.title('Save Session')
.textContent('Just a dialog test')
.ariaLabel('test dialog')
.ok('Got it!')
.targetEvent(ev);
);
};
And error text from console:
TypeError: $mdDialog.alert(...).parent(...).clickOutsideToClose(...).title(...).textContent is not a function
Angular material is the latest version downloaded two days ago.
I just encountered a similar problem with $mdtoast (using 0.11.4)
It Might or might not be related...
TypeError: $mdToast.simple(...).textContent is not a function
at n.$scope.confirmToast (xxx.html:962)
at Auth.$authWithPassword.then.$scope.error (xxx.html:970)
at angular.js:13248
at n.$eval (angular.js:14466)
at n.$digest (angular.js:14282)
at n.$apply (angular.js:14571)
at angular.js:16308
at e (angular.js:4924)
at angular.js:5312(anonymous function) @ angular.js:11655(anonymous function) @ angular.js:8596(anonymous function) @ angular.js:13256n.$eval @ angular.js:14466n.$digest @ angular.js:14282n.$apply @ angular.js:14571(anonymous function) @ angular.js:16308e @ angular.js:4924(anonymous function) @ angular.js:5312
@mathiasleroy the version of Angular Material you are using (0.11.4) is out of date, and does not have a "textContent" function. The interface for a lot of these things have changed. You are looking for ".content" instead. Please change the version of the angular docs, to your version to see the correct API interface.
Ok, found the problem, I had the 0.11.4 as well, I thought the bower pulled down the 1.0.0-rc5, but it did not, I manually set bower to download the version 1.0.x and then it worked.
Probably the others are having the same problem for the same reason.
I got a same issue.
@yahoohung did you check if you are at version 1.0.0 and not 0.11.4?
@darkmavis1980 thanks, just ran into the identical scenario. pulling 1.0.0-rc5 now.
https://material.angularjs.org/latest/demo/toast
Documentation needs updating
thanks guys, was in same issue. manually version pull from bower resolve issue.
for version 0.11.4,its just content not textContent.
$mdToast.show($mdToast.simple().content('Simple Toast!').position('right top').hideDelay(3000));
thanks guys change version and it works fine.
Most helpful comment
for version 0.11.4,its just content not textContent.
$mdToast.show($mdToast.simple().content('Simple Toast!').position('right top').hideDelay(3000));