Monthly Archives: December 2017
IE11 and String.prototype.includes() in Angular directives
Just come across an interesting behaviour with Angular directives and E11. Apparently E11 does not seem to work with the function String.prototype.includes(), for example:
[code language=”html”]
<div ng-if="str.includes(‘test’)" class="someClass"><span>Some text</span></div>
[/code]
where str == ‘Sometest‘ and the generic syntax is as below:
str.includes(searchString[, position])
Browser’s compatibility is an issue with IE11 and generally speaking it is poor across IE, so it is highly recommended to use this, instead:
[code language=”html”]
<div ng-if="str.indexOf(‘test’) >= 0" class="someClass"><span>Some text</span></div>
[/code]
as per the syntax below:
str.indexOf(searchValue[, fromIndex])
IndexOf method returns the index of the string as passed in. If the value is not found, it returns -1.
Further documentation:
You must be logged in to post a comment.