I have an AngularJS function that uses JavaScript's RegExp() to look for a character at the start of a string. In this case, it's a lowercase p.
$scope.checkState = function(state){
var page = state;
console.log(page);
var regex = new RegExp("^[p]");
var check = regex.exec(page);
console.log('Regex evaluated to: ' + check);
if (check == "p")
return false;
else
return true;
}
On the main HTML page, there is a button that is checking for an answer to the status of checkState(). If it returns as false, it hides the button from view with ng-show.
<md-button class="md-raised md-warn btn-right" ng-show="checkState({{pageID}})" ng-model="thing" ng-cloak onclick="thing()">My Button</md-button>
In here, pageID is a variable that contains a given ID value of a page template. When called in Angular, pageID becomes a string that is passed to the checkState() function.
Right now, I have been able to get the script to evaluate to null, but not to any other results. This is because despite the variable being filled in programatically, I get undefined instead.
What's going on here?
ng-show="checkState(pageID)"and that should work