This lesson covers using the [input] syntax to change an element property such as “hidden” or “content-editable”. Using properties eliminates the need for Angular 1’s old directives such as ng-show and ng-hide as you’re now able to directly access any property on your element.

todoService.ts

export class TodoModel{status: string = "started";constructor(public title: string = ""){}toggle(): void{if(this.status === "started") this.status = "completed";else this.status = "started";}
}

todoList.ts

import {Component, View, NgFor} from 'angular2/angular2';
import {TodoService} from './todoService';@Component({selector: 'todo-list'
})
@View({directives: [NgFor],template: `<div><div *ng-for="#todo of todoService.todos"><span [content-editable]="todo.status === 'started'">{{todo.title}}</span><button (click)="todo.toggle()">Toggle</button></div></div>
    `
})export class TodoList{constructor(public todoService:TodoService){}
}

转载于:https://www.cnblogs.com/Answer1215/p/4910173.html

[Angular 2] Template property syntax相关推荐

  1. Angular HTML template的解析位置

    文件: compiler.umd.js path: turbo_modules/@angular/compiler@9.1.12/bundles: 函数名:TemplateParser.prototy ...

  2. ASP.NET Core + Angular 2 Template for Visual Studio

    多个月以来,我和多个Github上的社区贡献者一起建立支持库.包,我们最终的目的是希望完成这样一个作为起点的模板,也就是基于把Typescript代码和Angular2宿主在ASP.NET Core项 ...

  3. To avoid scope ambiguity, the default slot should also use <template> syntax when there are other na

    具名插槽 https://cn.vuejs.org/v2/guide/components-slots.html <base-layout><template v-slot:head ...

  4. Angular里的property binding的一个例子

    如果src不加中括号,hero.url会被当成静态的字符串,传递给src属性: 当然最后啥图片也不会显示出来: 正确的办法:实现一个get函数,返回正确的图片url: Component模板源代码: ...

  5. Angular Component template函数执行上下文的对象

    下图第1行代码,定义的model变量,在Chrome调试器里的名称不是model,而是model_r1:

  6. angular react_Angular 2 vs React:将会有鲜血

    angular react Angular 2 has reached Beta and appears poised to become the hot new framework of 2016. ...

  7. Angular component的一个例子

    官网:https://angular.io/guide/architecture-components Before a view is displayed, Angular evaluates th ...

  8. 在Angular专家Dan Wahlin的免费33部分课程中学习Angular

    According to the Stack Overflow developer survey 2018, Angular is one of the most popular frameworks ...

  9. Angular form学习笔记

    https://angular.io/start/start-forms Angular里的form分成两部分: the objects that live in the component to s ...

最新文章

  1. node.js是做什么的?
  2. 在C#中调用windows API函数
  3. centos7安装nginx和php,centos7安装nginx1.10和php7
  4. 深入理解 JVM Class文件格式(十)
  5. 拥有成本分析:Oracle WebLogic Server与JBoss
  6. vuex最简单、最详细的入门文档
  7. ImageList控件 图片容器控件 1130
  8. Upload-Labs(17-20)
  9. ueditor如何去掉末尾的p标签_织梦dedecms如何去掉域名后面的index.html
  10. PHP对象和接口抽象类注意事项
  11. python获取cookie值的方法_Python获取Cookie、设置Cookie的N种方法
  12. 天涯明月刀微信群服务器名称,微信群名称大全
  13. 【数据结构】线段树(interval tree)
  14. ubuntu安装阿里源
  15. win10商店打不开_Win10应用商店出现异常打不开三种解决方法
  16. 【ChatGPT】70 款 ChatGPT 插件评测:惊艳的开发过程与宏大的商业化愿景
  17. 爱宝 A-80P 打印机驱动
  18. 微信小程序在线点餐外卖小程序实现方法适合校园点餐毕业设计小程序(含代码解释)
  19. ffmpeg 一张图片转视频
  20. 使用小程序制作一个电子木鱼,功德+1

热门文章

  1. Yahoo 其实比你想的更糟糕!
  2. java中io与nio复制文件性能对比
  3. centos关机与重启命令详解
  4. Android开发(五)——计时器
  5. c++ split 方法(转)
  6. 一段简单的模拟服务器的代码(Selector)
  7. 【哲学】罗素《哲学问题》,把我从怀疑派拉回来,本能信仰
  8. Ajax搜索结果页面下方的分页按钮的生成
  9. 40个非常有创意的404页面设计作品
  10. 从“学徒”(Apprentice III)看领导力(9-17集)