嗨,我从http.get的数据库中获取文本。如何使用浏览器检测?如何使用if子句?我不想使用translate.toogle()
var mainCtrl = function ($scope,$http,$sce,$location,$timeout,$routeParams,toastr) { $scope.showPage = false; $timeout(function(){ $scope.showPage = true; },2000); $scope.trustedHtml = function (plainText) { return $sce.trustAsHtml(plainText); } $http.get('admin/api/?s=getAbout').success( ##### if browser En_en function(r){ $scope.about = r.text_en; ##### if browser De_de function(r){ $scope.about = r.text_de; } ); };
您可以使用navigator.language获取浏览器语言:
原文链接:https://www.f2er.com/angularjs/144460.htmlvar lang = $window.navigator.language || $window.navigator.userLanguage; if (lang === 'en-US') { console.log("language is english"); }