I am trying to create a "confirm" button for users of my website to see when they click on a button, and I am using an angularJS class. My code is as follows:
class TodosListCtrl {
constructor($scope, $window){
$scope.viewModel(this);
this.$scope = $scope;
}
//... a bunch of functions
Clear(){
var delete = this.$scope.confirm("Are you sure you want to clear the text?");
if(delete){
//delete stuff
}
}
But every time I click on the button that calls the "Clear()" function, I get the error
"this.$scope.confirm is not a function at TodosListCtrl.Clear"
Does anyone know why this is happening, and how I can fix this?
Just take this.$scope
off of this.$scope.confirm
:
class TodosListCtrl {
constructor($scope, $window){
$scope.viewModel(this);
this.$scope = $scope;
}
//... a bunch of functions
Clear(){
var delete = confirm("Are you sure you want to clear the text?");
if(delete){
//delete stuff
}
}