1

I have the ng-include below, the file name it's getting contains an ñ character so it's showing an not found error.

<div ng-include="'{{mainCtrl.name}}.html'"></div>

I also tried using decodeURI like the code below before passing it to the ng-include but it didn't work.

self.name = decodeURI(self.name);

I already have <meta charset="utf-8"> and <script type="text/javascript" charset="UTF-8"> and I already tested if decodeURI works in my javascript and it does.

Is there some way ng-include could read the ñ character?

Len
  • 534
  • 1
  • 15
  • 31

2 Answers2

1

Its basically issue with ng-include use ng-include src instead.

Please use the following:

<div ng-include src = "mainCtrl.fullName"></div>

And in controller use the following

self.fullName = self.name + ".html";
I. Ahmed
  • 2,438
  • 1
  • 12
  • 29
  • unfortunately `self.name` is dynamic, I called it using https. – Len Mar 12 '18 at 03:01
  • Update for dynamic value. Just use replace method after dynamic value stored – I. Ahmed Mar 12 '18 at 03:27
  • I don't think the issue was `ng-include src ` because I already changed it to that before, but it only worked when I added the `+".html"; ` – Len Mar 12 '18 at 05:42
1

The workaround below worked for me, UTF-8 characters seems to be readable if it's called inside a function first.

html

<div ng-include src="mainCtrl.getName()"></div>

ctrl.js

self.getName= function () {
     return self.name+'.html';
}
Len
  • 534
  • 1
  • 15
  • 31