cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <body ng-app="arabicNumberApp">

<div ng-controller="MainCtrl">
	<h1>Custom AngularJS filter</h1>
	<p>
		Creating custom AngularJS filters to convert Latin script (English) numbers to Arabic numbers based on current user locale
	</p>
	<form>
	<label for="">Change User Locale</label>
	<select ng-model="lang">
		<option value="ar">Arabic</option>
		<option value="en">English</option>
	</select>
	</form>
	<p class="number">
		{{ myNumber | ngArabicNumber:(lang === 'ar') }}
	</p>
	
</div>
  
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js"></script>
  
</body>

            
          
!
            
              @font-face {
	font-family: 'Noto Kufi Arabic';
	font-style: normal;
	font-weight: 400;
	src: url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Regular.eot);
	src: url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Regular.eot?#iefix) format('embedded-opentype'), url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Regular.woff2) format('woff2'), url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Regular.woff) format('woff'), url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Regular.ttf) format('truetype');
}
@font-face {
	font-family: 'Noto Kufi Arabic';
	font-style: normal;
	font-weight: 700;
	src: url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Bold.eot);
	src: url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Bold.eot?#iefix) format('embedded-opentype'), url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Bold.woff2) format('woff2'), url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Bold.woff) format('woff'), url(//fonts.gstatic.com/ea/notokufiarabic/v2/NotoKufiArabic-Bold.ttf) format('truetype');
}

body { margin: 20px; }
body,
html, p {
    font-family: "Noto Kufi Arabic", sans-serif !important;
}

h1 {
	font-size: 18px;
	font-weight: bold;
}
p {
  font-size: 16px;
}
.number {
	color: blue;
	font-size: 24px;
}
            
          
!
            
              var myModule = angular.module("arabicNumberApp", []);

myModule.filter('ngArabicNumber', function() {
  return function (number, isArabic) {

    function _arabicNumber(value, isArabic) {
			
			if (!value) {
        return;
      }

      var englishNumbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
          arabicNumbers = ['١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩', '٠'];

      for (var i = 0, numbersLen = englishNumbers.length; i < numbersLen; i++) {
        value = value.replace(new RegExp(englishNumbers[i], 'g'), arabicNumbers[i]);
      }
      return value;
    }

    if (isArabic) {
      if (number.toString().trim() !== '') {
        return _arabicNumber(number.toString(), isArabic).toString();
      }
    } else {
      return number;
    }
  }
});


myModule.controller("MainCtrl",['$scope', function($scope){
  $scope.myNumber = 10;
  $scope.lang = 'ar';
}]);
            
          
!
999px
Loading ..................

Console