由灯塔测量的Hello World Angular CLI(为什么速度慢,数量巨大?)(Hello World Angular CLI as Measured by Lighthouse(Why slow and enormous?))
是否需要对Angular CLI Hello World应用优化,还是这是一个有效的“性能”结果?
在将Lighthouse应用到我们的实时角度4项目中时,我们将其与Angular CLI Hello World进行了比较。
从控制台:
npm install -g @angular/cli ng new my-dream-app cd my-dream-app ng serve --prod
在Chrome中 - > F12 - >审核 - >运行灯塔。
- 表现为39/100。
- 第一个有意义的油漆是15,250ms
- 感知速度指数:15,248(目标:<1,250)
- 拥有巨大的网络负载:总大小为2,453 KB(目标:<1,600 KB)
更新1
Thx to @Moshe,使用:
ng serve --prod --build-optimizer
给出以下内容: - 性能为96/100。 - 第一次有意义的涂料是2,040ms - 感知速度指数:2,054(目标:<1,250); 92/100等级
最终难以形成一个单一的,简洁的问题。 我了解
ng serve
不适合生产使用,即使使用ag也是如此。但是,这允许我在发布之前在本地主机上进行测试。Do optimizations need to be applied to the Angular CLI Hello World or is this a valid "performance" result?
In applying Lighthouse to our live angular 4 project, we compared to the Angular CLI Hello World.
From console:
npm install -g @angular/cli ng new my-dream-app cd my-dream-app ng serve --prod
In Chrome -> F12 -> Audits -> Run Lighthouse.
- Performance is 39/100.
- First Meaningful Paint is 15,250ms
- Perceptual Speed Index: 15,248 (target: < 1,250)
- Has enormous network payloads: Total size was 2,453 KB (target: < 1,600 KB)
Update 1
Thx to @Moshe, using:
ng serve --prod --build-optimizer
Gave the following: - Performance is 96/100. - First Meaningful Paint is 2,040ms - Perceptual Speed Index: 2,054 (target: < 1,250); Grade of 92/100
Ultimately had a difficult time forming a singular, concise question for this. I understand
ng serve
is not for production use, even with ags.. But this allows my to test on my localhost before publishing.
原文:https://stackoverflow.com/questions/46084009
最满意答案
你可以这样做http://jsfiddle.net/HB7LU/10720/
<div ng-repeat= "user in filteredValue = (value | filter:query)"></div>
只需将过滤后的结果用作另一个名为
filteredValue
范围变量,然后就可以在控制器范围内获取其长度You can do this http://jsfiddle.net/HB7LU/10720/
<div ng-repeat= "user in filteredValue = (value | filter:query)"></div>
Just use the filtered result as another scope variable, named
filteredValue
, then you can get its length, within the scope of the controller
相关问答
更多-
对于第二个问题,您可能希望创建一个函数来处理“ALL”的情况,因为它的返回值将是“undefined”,所以它看起来像:
{{ showGroup(group) }} 然后在角度代码内: $scope.showGroup = function(group) { if( group == 'undefined' ) return "All"; else return group; }; 而且滤镜数组的长度在上面的 ... -
将search.length替换为(employee |filter:search).length == 0 。
No Data found No Data found -
尝试这个: Search: 在你的控制器里面: $scope.getData = function (names, query) { $scope.queryData = $filter('filter')(names, query)); }; 所以$ scope.queryData现在是你的结果集合。 Try this: Search:
如何知道AngularJS过滤和限制列表长度是否相同(How to know if AngularJS filtered and limited lists lengths are the same)[2022-01-06]
var newapp = angular.module('someapp',[]); newapp.service('limitcheck', [function(){ return { checkLimit : function (arr) { if (arr.length > 6) { alert('The array has more than 6 entries'); } } }; }]); newapp.filter('d ...不幸的是,没有办法避免运行过滤器两次,而不写一些javascript来将过滤器的结果赋值给一个变量。 所以,一种解决方案是在阵列发生变化时在控制器中运行selectedTag筛选器,将其存储在本地并在视图中使用它。 将此代码添加到您的控制器中: .controler($scope, $filter) { // Existing code $scope.array = ... $scope.selectedTag = ... // New code $scope.fi ...AngularJS过滤ng-repeat,如何访问过滤的数据(AngularJS Filter for ng-repeat, how to get access to the filtered data)[2022-03-11]
好的,所以错误是由每次调用applyFilter时创建的新数组引起的。 我不确定为什么实际的过滤器工作(即在视图中)而不是在函数中,因为他们正在做同样的事情! 但是我可以通过使用angular.equals来解决这个问题。 首先当我得到数据时,我必须将结果存储到一个单独的数组中,然后当我调用我的过滤器时,我可以使用未修改的数组。 // Get our report provider.overdueCollections().then(function (response) { self.models ...你可以这样做http://jsfiddle.net/HB7LU/10720/ 只需将过滤后的结果用作另一个名为filteredValue范围变量,然后就可以在控制器范围内获取其长度 You can do this http://jsfiddle.net/HB7LU/10720/您可以使用过滤器直接在ng-repeat内部进行filter $scope.barcode = ""; $scope.conditionalFilter = function(item){ if ($scope.barcode !== "") { return item.barcode === $scope.barcode; // return items only if barcode is selected } else { return true; // return all ...您可以将过滤后的数据存储在filteredList中并将其传递给计算,{{$index+1}} {{user.name}} {{user.age}} 从语义上讲,重新安排数据会更有意义。 变成这样的东西。 [ { id: 1, title: 'Parent 1', items: [ {id: 126, description: 'Item 1'}, {....} ] } ] 然后使用嵌套重复。 这种数据结构更准确地描述了实际情况,并将使您的生活更轻松。 如果重新排列数据不是一个选项,或者您不了解嵌套的ng-repeats让我知 ...相关文章
更多- 【z】Storm - the world's best IDE framework for .NET
- Spring Boot CLI单元测试
- The Greatest Salesman In the World
- Hadoop 2.0.0-alpha尝鲜安装和Hello world
- Storm实时流处理Hello World
- Hadoop Real-World Solutions Cookbook
- Solr4:Hello World级别示范
- Angular实践----前言与概览
- Spring Boot CLI 基于Thymeleaf的示例
- Spring Boot CLI快速入门程序
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)