My Angular 2 application has been throwing an error message stating "Error: Error in ./SampleComponent class SampleComponent - inline template caused by: Variable undefined in strict mode". Strangely, this error only occurs in IE 10.
<input type="text" class="form-control" name="name" formControlName="name" placeholder="Name" [nameFormatter]="selected">
The issue seems to stem from the "selected
" value that is being passed to the attribute directive nameFormatter
. This variable is initially set within the component. Interestingly, if I replace the selected
variable with a static value, everything works fine. It's only when attaching it to the selected
variable that the problem arises.
export class NameComponent implements OnInit {
public selected : string;
someFunction(){
this.selected="some value"; //The value changes depending on certain conditions
}
}
I have tried adding polyfills to index.html in an attempt to resolve this issue, but without success. Here are the polyfills I added:
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.min.js"></script>
<script src="https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
If anyone could provide guidance on how to tackle this problem, I would greatly appreciate it.