Angular中的法国口音显示 [英] French accent display in Angular

查看:72
本文介绍了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中显示变量时,我也遇到同样的问题.我明白了:电话

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆