`

angular js: filter vs format

 
阅读更多

Filter transform the model to the display in view.

Formatter transform the display in view to model.

 

Filter
  <input type="text" name="objTxt" value="{a:1, b:[]}"
         ng:eval="obj = $eval(objTxt)"/>
  <pre>{{ obj | json }}</pre>


Formatter
  <div ng:init="data={name:'misko', project:'angular'}">
    <input type="text" size='50' name="data" ng:format="json"/>
    <pre>data={{data}}</pre>
  </div>
分享到:
评论

相关推荐

    angular-datetimepicker

    首先,AngularJS是一个流行的JavaScript框架,由Google维护,用于构建单页应用程序(SPA)。它使用MVC(模型-视图-控制器)架构模式,提供了数据绑定、依赖注入等特性,极大地简化了前端开发。"angular-...

    前端项目-angular-numeraljs.zip

    在本项目"前端项目-angular-numeraljs.zip"中,我们主要关注的是如何在AngularJS框架中集成和使用Numeral.js库。AngularJS是一款强大的前端JavaScript框架,它通过数据绑定和依赖注入来简化Web应用的开发。Numeral....

    AngularJS实现的自定义过滤器简单示例

    angular.module('demo').filter('stateFormat', ['state', function (state) { return function(input, type){ switch (type) { case 'stateColor': // 根据输入值返回对应颜色 switch (input) { case '1': ...

    深入理解angularjs过滤器

    姓名:{{list.name}}, 人数{{(lists | my_data_format:'2').length}} ``` 自定义过滤器可以非常灵活地处理数据。例如,以下过滤器 my_data_format 能够根据传入的 status 条件过滤数组中的对象: ```javascript ...

    AngularJS 日期格式化详解

    在JavaScript代码中,可以使用$filter服务来获取'date'过滤器,并应用它来格式化日期。这种做法通常在控制器或自定义指令中使用。使用$filter服务时,先注入$filter服务,然后调用过滤器函数,并传入要格式化的日期...

    Angularjs过滤器使用详解

    这样,你可以根据过滤条件动态控制列表的显示,或者在`ng-if="(lists | my_data_format: '2').length &gt; 0"`中检查特定状态的列表项数量,以决定是否显示某个元素。 总之,AngularJS过滤器是数据呈现和处理的关键...

    python3.6.5参考手册 chm

    New Documentation Format: reStructuredText Using Sphinx PEP 343: The ‘with’ statement Writing Context Managers The contextlib module PEP 366: Explicit Relative Imports From a Main Module PEP 370...

Global site tag (gtag.js) - Google Analytics