npm

angular-cherry-pick

0.0.1 • Public • Published

What is this?

This is nearly equivalent as follows.

<ANY ng-repeat="option in options|filter:{id:selectedId}:true">{{option.title}}</ANY>

Use case

In a controller, some array defined.

$scope.options = [
  {id:1, title:'foo'},
  {id:2, title:'bar'},
  {id:3, tille:'baz'}
]

In a template, a drop-down list uses the defined array.

<select ng-options="option.id as option.title for option in options"
  ng-model="selectedId"></select>

And, render a element as title' property notid' property.

{{options|cherrypick:{id:selectedId}:'title'}}

Usage

Add the module to your application.

angular.module('myApp', ['ngCherryPick']);

Add the filter to a binding.

{{mylist|cherrypick:{id:100}:properyName}}

Why does not bind a object, but a id.

Because the world is complex...

Of course, You can goes on a simple way.

<select ng-options="option as option.title for option in options"
  ng-model="selected"></select>

{{selected.title}}

Package Sidebar

Install

npm i angular-cherry-pick

Weekly Downloads

1

Version

0.0.1

License

BSD-3-Clause

Last publish

Collaborators

  • sengokyu