Angular 1.x.x中的全名格式

时间:2018-08-21 05:01:32

标签: html5 angularjs-directive angular1.6

如何根据Angular 1.x.x中的语言环境呈现全名(名字+姓氏/姓氏+名字)。我将“名字”,“姓氏”和“语言环境”作为字符串

我目前有一个地区列表及其全名排序方案。 [前+后]或[后+前]

控制器:

$ctrl = this; 
$ctrl.firstName = "John"; 
$ctrl.lastName = "Doe"; 
$ctrl.locale = languageService.langLocale(); 
var fullnameGen = function(firstName, lastName) { 
    var order = getOrder(locale); 
    var fullname = ""; 
    for(ele in order) { 
       switch(ele){ 
          case FIRST_NAME: fullname += firstName; 
          case LAST_NAME: fullname += lastName; 
       }
    } 
} 
$ctrl.fullName = fullNameGen(firstName,lastName);

查看:

<div> Full Name: </div> <div> {{$ctrl.fullName}} </div>

0 个答案:

没有答案