-
-
Notifications
You must be signed in to change notification settings - Fork 240
Description
I built Groceries as an ng2 web app (see https://github.com/tjvantoll/Groceries), and I’m trying to port as much of that code as possible to the Groceries {N} app.
One thing that struck me is just how much harder it is to build a list in {N}. For Groceries web I was able to trivially bind a <ul> to an array of objects. In {N} trying to accomplish the same task is considerably harder. Here’s a short list of things I’ve found that I have to do. (The full code is in this .html file and this .ts file.)
- Use
<item-template>and<template>instead ofngFor. I realize this is due to the difference in how our ListView works, but I thought it was still work explicitly mentioning. - Use the
asyncpipe in my template. - Set the component’s
changeDetectiontoChangeDetectionStrategy.OnPush. - Bind to an
rxjs/Observableinstead of just a simple array. - Wrap the array in a
WrappedValueso that {N} recognizes pushes to the array.
Really all I want to do is bind the <ListView> to a simple array like I can do in ng2 web apps, so if at all possible I’d love to see 2–5 above go away. <ListView>s are really common and I don’t think I’ll be the first person to be confused by these requirements. Removing them would also allow for more code reuse between {N} and web apps.