[Angular 2] ng-model and ng-for with Select and Option elements
You can use Select and Option elements in combination with ng-for and ng-model to create mini-forms that change your data as you make a selection.
/**
* Created by wanzhen on 23.10.2015.
*/
import {Component, View, NgFor, FORM_DIRECTIVES} from 'angular2/angular2';
import {TodoService} from './todoService';
import {TodoItemRender} from './todoItemRender';
import {StartsWith} from './startsWith'; @Component({
selector: 'todo-list'
})
@View({
pipes: [StartsWith],
directives: [NgFor, TodoItemRender, FORM_DIRECTIVES],
template: `
<div>
<todo-item-render
*ng-for="#todo of todoService.todos | startsWith:'title':selectedLetter"
[todoinput]="todo"
>
</todo-item-render>
<select [(ng-model)]="selectedLetter">
<option *ng-for="#letter of letters">{{letter}}</option>
</select>
</div>
`
}) export class TodoList{
letters: string[] = ['e', 's', 'w'];
selectedLetter: string = 'e';
constructor(
public todoService:TodoService
){ }
}
[Angular 2] ng-model and ng-for with Select and Option elements的更多相关文章
- Angular 中后台前端解决方案 - Ng Alain 介绍
背景 之前项目使用过vue.js+iview,习惯了后端开发的我,总觉得使用不习惯,之前分析易企秀前端代码,接触到了angular js,完备的相关功能,类似后端开发的体验,让人耳目一新,全新的ang ...
- angular.min.js:118 Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?
1,错误如图所示 简单说下错误原因是:没有js没有注册进去. 解决方法: 1.看下index.html有没有引入你的js文件. 2.看下app.js有没有注册js,比如我这次就是这步没做好,合并代码时 ...
- AngularJS中angular.min.js:80 Error: [ng:areq] http://errors.angularjs.org/1.2.9/ng/areq
报出来的时候,出现这种错误,是因为在引入控制器的时候没有引入成功,我遇到这个错误是在因为没有将父控制器引入到子控制器中.
- 在库中使用schematics——ng add与ng update
起步 创建一个angular库 ng new demo --create-application=false ng g library my-lib 可见如下目录结构 ├── node_modules ...
- Part 14 ng hide and ng show in AngularJS
ng-hide and ng-show directives are used to control the visibility of the HTML elements. Let us under ...
- Angular6之ng build | ng build --aot | ng build --prod 差异
由于写了大半年的项目终于要告一段落并且即将进行第二阶段优化开发,emmm 基础版本已经二十多个模块了,必不可少的优化是很重要的,尽管项目上使用多层嵌套懒加载,但是在首屏加载的时候,任然很慢啊,因为一直 ...
- Angular 学习笔记 (Custom Accessor + Mat FormField + Custom select)
custom form control 之前就写过了,这里简单写一下. 创建一个组件实现 ControlValueAccessor 接口 @Component({ providers: [ { pro ...
- angular select框 option空行
1.使用option <select class="form-control" ng-model="searchType"> <option ...
- [Angular2 Form] Build Select Dropdowns for Angular 2 Forms
Select Dropdowns in Angular 2 a built with select and option elements. You use *ngFor to loop throug ...
随机推荐
- centos6.2下搭建Web服务器
1.安装Apache2 yum install httpd 2.启动 方法一:service httpd start 方法二:/etc/init.d/httpd start //浏览http://ip ...
- Obj-C的hello,world 1
不得不说,Obj-C所谓的中缀表达式真的蛮奇怪的,当无参或者只有一个参数时看起来还不错: //无参数的方法 -(void) say; [employee say]; //只有一个参数的方法 -(voi ...
- jQuery取CSS的HEX(16位)颜色值
//IE10以上版本.CHROME.FIREFOX中GRB颜色转HEX颜色值 $.fn.getBackgroundColor = function() { var rgb = $(this).css( ...
- GNU PID
多进程编程 写在前面的话 本文主要根据本人在UNIX系统上的编程实践经验总结而成, 既做为自己在 一个时期内编程实践的部分总结, 又可成为文章发表. 对UNIX程序员初学者来 说是一个小小的经验, 仅 ...
- http头
http://hi.baidu.com/poplarshine/item/219bbef35f1d1d10d6ff8cf9 http://www.cnblogs.com/meil/archive/20 ...
- codeforces C. Devu and Partitioning of the Array
题意:给你n个数,然后分成k部分,每一个部分的和为偶数的有p个,奇数的有k-p个,如果可以划分,输出其中的一种,不可以输出NO; 思路:先输出k-p-1个奇数,再输出p-1个偶数,剩余的在进行构造. ...
- sql server 发布时提示'dbo.sysmergepublications'无效的解决办法
对数据库进行数据库复制.订阅时经常会出现各种奇怪的问题 如果你对数据库进行多次发布.删除发布操作时可能会提示“dbo.sysmergepublications”无效的问题, 可以使用以下方法解决: U ...
- 【转】ConcurrentModificationException异常解决办法 --不错
原文网址:http://blog.sina.com.cn/s/blog_465bcfba01000ds7.html 1月30日java.util.ConcurrentModificationExcep ...
- Android Studio导入Eclipse项目
随着Google 对新Android编辑器Android Studio(以下简称AS)的版本不断更新,越来越多的人开始由熟悉的编辑器Eclipse转向AS,而Eclipse开发团队也坦言将放弃对Ecl ...
- 动态规划(水题):COGS 261. [NOI1997] 积木游戏
261. [NOI1997] 积木游戏 ★★ 输入文件:buildinggame.in 输出文件:buildinggame.out 简单对比时间限制:1 s 内存限制:128 MB S ...