I want to know if it's possible to know if there are a char in a $scope for example something like this but in angularJs
$scope.test = "Hi, How Are You?";
if($scope.test.Contains("?")) {
return true
} else {
return false
}
I want to know if it's possible to know if there are a char in a $scope for example something like this but in angularJs
$scope.test = "Hi, How Are You?";
if($scope.test.Contains("?")) {
return true
} else {
return false
}
You can just replace Contains
with match
:
if($scope.test.match("?")) {
return true
} else {
return false
}
And you can even further optimize this whole code block to just:
return !!$scope.test.match("?");
Well you can do it like this..
var string = "hello";
alert(string.indexOf("llo") != -1);
so in regards to your code above..
$scope.test= "HI How Are You ?";
alert($scope.test.indexOf("How") != -1); // return true;
Try the codes below:
ng-attr-target="{{(p.link.indexOf('https://')!=-1) ? '_blank' : _self}}"