Underscore.js and Angular

Reference: http://underscorejs.org/

Installation and Import

  • Node.js > npm install underscore
  • import * as _from 'underscore'; 
Example:
In app.component.ts
import * as _ from 'underscore';

import { Component } from '@angular/core';
import
* as _ from 'underscore';
@
Component({selector: 'app-root',template: `<h1>even: {{even}}</h1>`
})
export
class AppComponent { even:any;constructor(){this.test();} 
 test(){ this.even = _.find([1, 2, 3, 4, 5, 6],
function(num){ return num % 2 == 0; });
}}

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE