Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

use javascript function in string interpolation angular

//angular HTML
{{secondsToHms(20)}}

//typescript
secondsToHms(d) {
    d = Number(d);
    var h = Math.floor(d / 3600);
    var m = Math.floor(d % 3600 / 60);
    var s = Math.floor(d % 3600 % 60);

    var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : "";
    var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : "";
    var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : "";
    return hDisplay + mDisplay + sDisplay; 
}
Comment

Angular JS Interpolation

<script>
  var customInterpolationApp = angular.module('customInterpolationApp', []);

  customInterpolationApp.config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('//');
    $interpolateProvider.endSymbol('//');
  });


  customInterpolationApp.controller('DemoController', function() {
      this.label = "This binding is brought you by // interpolation symbols.";
  });
</script>
<div ng-controller="DemoController as demo">
    //demo.label//
</div>
Comment

AngularJs: How to interpolate an interpolated string

$interpolate("Users({{users_count || 0}})")($scope)
Comment

PREVIOUS NEXT
Code Example
Javascript :: angularjs How to render either a number or a HTML element depending on what a function returns 
Javascript :: AngularJS two different actions in ng-submit 
Javascript :: call method from parent 
Javascript :: Angularjs to Angular Migration: factory prototype 
Javascript :: Prevent the wiping of an Array after routing Angular.js 
Javascript :: angular chart js graph legend colors 
Javascript :: createaction ngrx example 
Javascript :: AngularJS slick carousel filter by attribute 
Javascript :: React Native Root Element, deciding on async call 
Javascript :: check if Popups and Redirects are allowed 
Javascript :: wrapping a span tag with an a tag with a href target same as the text of the span 
Javascript :: Render JOSN in frontend 
Javascript :: reduce dot notations to javascript array 
Javascript :: node-mongodb-native keep collection 
Javascript :: ant design rtl 
Javascript :: Using Bind() With BuiltIn JavaScript Function 
Javascript :: echarts js 
Javascript :: Importing Ky Module In JavaScript 
Javascript :: Example: How to use || operator to shorten the code. 
Javascript :: Creating Genesis Block for blockchain 
Javascript :: Declaring A Internal Method Of A Class 
Javascript :: Javascript Area When Base and Height is Known 
Javascript :: number of substring in a string 
Javascript :: Nodejs change host on npm run dev 
Javascript :: Looping through array, fetching tweets and returning new reversed array javascript react 
Javascript :: onclick readmore and readless react js 
Javascript :: Backbone Template 
Javascript :: name of javascript virtual machine for apple 
Javascript :: adding javascript object within array in the middle position 
Javascript :: js pipe 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =