javascriptangularjsutf-8decodeuricomponent

ng-include not getting file name with utf-8 character


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?


Solution

  • 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";