Angular 中的法语口音显示 [英] French accent display in Angular
问题描述
我在 services.js 文件中定义了一个变量,并通过工厂提供给我的控制器.此变量包含法语口音.下面是一个例子:
I have a variable defined in my services.js file and made available to my controller via a factory. This variable contains French accents. Here is an example:
angular.module('starter.services', [])
.factory('Telephone', function() {
var telephone = 'Téléphone';
return {
getVariable: function() {
return telephone;
}
};
})
问题是,当我通过范围在控制器中显示我的变量时,重音的格式不正确(我得到了一些奇怪的字符).这是我的控制器:
The problem is, when I display my variable in the controller via the scope, the accents are not formatted properly (I get some weird characters instead). Here is my controller:
.controller('DashCtrl', function($scope, Telephone) {
$scope.telephone = Telephone.getVariable();
console.log('Telephone = ' + $scope.telephone); //Here I get badly formmatted accents, something like T�l�phone instead of Téléphone
})
当我在 HTML 中显示变量时,我也遇到了同样的问题.我明白了:T l phone
I have also the same problem when I display the variable in HTML. I get this: T�l�phone
我所有的 HTML 模板都正确编码 (UTF-8).
All my HTML templates are properly encoded (UTF-8).
在此先感谢您的帮助.里亚德
Thanks in advance your help. Riadh
推荐答案
您需要将 é 更改为 é.因此,评估会将 é 转换回 é
You need to change é to é. So the evaluation will translate é back to é
angular.module('starter.services', [])
.factory('Telephone', function() {
var telephone = 'Téléphone';
return {
getVariable: function() {
return telephone;
}
};
})
这篇关于Angular 中的法语口音显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!