Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ModeSix
Mar 14, 2009

Skandranon posted:

It's not strange, you're not thinking right on how ng-repeat works. The first part of "comments in dishDetailCtrl.dish" is just giving the name you want to the iterator. Similar to a "foreach (string x in names)" loop, the name of the iterator need not have any connection to the collection. You could have said "aaaaaa in dishDetailCtrl.dish" and the results are the same. Your problem is in telling Angular what to iterate over. In the first case, (dish), it ends up just repeating over each property in dish, (of which there are 7), and trying to print out the rating property on each of those objects (which is always undefined). In the second case, (dish.comments), you iterate over each item in the dish.comments array, and print out the rating property on each of them (which does exist).

It's strange for me coming from a dot notated language like C++/C#. I come from a different part of CS and the way the Angular(or just JavaScript?) notation works is slightly odd in comparison.

However, I understand it now and won't get caught by this mistake again. I hope.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



ModeSix posted:

It's strange for me coming from a dot notated language like C++/C#. I come from a different part of CS and the way the Angular(or just JavaScript?) notation works is slightly odd in comparison.

However, I understand it now and won't get caught by this mistake again. I hope.

Since you're familiar with C#, I'm pretty sure the equivalent is

code:
foreach(var comment in dishDetailCtrl.dish.comments)
//comment is the loop variable, comments is the collection

ModeSix
Mar 14, 2009

Munkeymon posted:

Since you're familiar with C#, I'm pretty sure the equivalent is

code:
foreach(var comment in dishDetailCtrl.dish.comments)
//comment is the loop variable, comments is the collection

Ok that makes sense. :v:

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Time for my once-every-few-months complaint about modern front-end development.

I put aside a project using modern front-end libraries for a a few months, did a few non-web-related projects, come back to it, have to spend a week or more upgrading all the libraries and fixing everything the upgrades broke.

Yeah, it's a lot my fault for using a bunch of modern, evolving stuff, but that was part of the point of this project.

I don't really blame the new, constantly-evolving projects for being constantly-evolving. I blame them for having terrible lovely changelogs and upgrade paths.

Prior the the past year or so I didn't spend a lot of time in the situation where I'd be setting projects aside like this. The experience has taught me that going forward I need to really evaluate how a library or framework does changelogs before adopting it.

Funnily enough, one of the non-web-related projects was a project I had also set aside for a few months...and on that one I had to upgrade just one library and it had no breaking changes.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Thermopyle posted:

Time for my once-every-few-months complaint about modern front-end development.

I put aside a project using modern front-end libraries for a a few months, did a few non-web-related projects, come back to it, have to spend a week or more upgrading all the libraries and fixing everything the upgrades broke.

Yeah, it's a lot my fault for using a bunch of modern, evolving stuff, but that was part of the point of this project.

I don't really blame the new, constantly-evolving projects for being constantly-evolving. I blame them for having terrible lovely changelogs and upgrade paths.

Prior the the past year or so I didn't spend a lot of time in the situation where I'd be setting projects aside like this. The experience has taught me that going forward I need to really evaluate how a library or framework does changelogs before adopting it.

Funnily enough, one of the non-web-related projects was a project I had also set aside for a few months...and on that one I had to upgrade just one library and it had no breaking changes.

Yep. Working with a startup and did the front-end in React / React-Router a few months ago, and it's working / all is well. After customer feedback and so on, time to make some changes! The other person on the project is going to do them, but got a new laptop.... nothing works. Oh, node is at 5.X and we were on 0.12.x... time to install nvm! Oh, we need to tweak some router stuff... look, the current docs look totally foreign!

:argh:

But like you said, it's the price you pay for choosing those tools.

abraham linksys
Sep 6, 2010

:darksouls:
fwiw you can get away with using old versions of React/libs if you want, my main project is still on react-router 0.13.x and some old Flux implementation because it works fine

React itself has had little enough churn that it's not hard to use old libs with new versions for now, haven't had any major compatibility issues

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

abraham linksys posted:

fwiw you can get away with using old versions of React/libs if you want, my main project is still on react-router 0.13.x and some old Flux implementation because it works fine

React itself has had little enough churn that it's not hard to use old libs with new versions for now, haven't had any major compatibility issues

Yeah, that's what we are doing (React 0.13, old router, old Alt, etc.) but it's just amazing that as a project that *started* six months ago, if you told someone to read up on React, Router, etc. today, they'd be seeing a whole different world in such a short time.

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

I recently looked into react router and found myself utterly confused as every tutorial I read seemed to be talking about something different.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
I'm rebuilding an electron app that currently renders jsx server side. Unfortunately this means we can't take advantage of React events or any of the nice bells and whistles.

I'm going to use express for the api but what's the goto for feeding data into React? Also how the poo poo does webpack work and how can I integrate it into an electron build workflow?

ModeSix
Mar 14, 2009

Angular is a whore.

So I am trying to do form validation and take the form data and use push() to an array.

It appears to work fine, but two problems.
1) The form doesn't get cleared (this isn't really important yet so I'm not even going to focus on it in this question)

2) When I hit submit it appears to append the data to the array, because it can be sorted, filtered etc. But if I modify what is in the form, it changes the data in the array.

I tried to set up a jsfiddle but I really don't get it, so here's my HTML.

http://pastebin.com/c4N6s0xh

Now here's the script.

http://pastebin.com/gC4KRSRg

The console log shows the form data correctly, and it actually moves the data up into the array (or so it appears). If I modify any data that is in the form the corresponding array data is changed for the new entry. I also cannot submit a second additional entry, just one submission and that's it.

I really am stumped because this should work based off of everything I've read.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

ModeSix posted:

Angular is a whore.

So I am trying to do form validation and take the form data and use push() to an array.

It appears to work fine, but two problems.
1) The form doesn't get cleared (this isn't really important yet so I'm not even going to focus on it in this question)

2) When I hit submit it appears to append the data to the array, because it can be sorted, filtered etc. But if I modify what is in the form, it changes the data in the array.

I tried to set up a jsfiddle but I really don't get it, so here's my HTML.

http://pastebin.com/c4N6s0xh

Now here's the script.

http://pastebin.com/gC4KRSRg

The console log shows the form data correctly, and it actually moves the data up into the array (or so it appears). If I modify any data that is in the form the corresponding array data is changed for the new entry. I also cannot submit a second additional entry, just one submission and that's it.

I really am stumped because this should work based off of everything I've read.

You shut your mouth!

As to your issue, it looks like you are trying to change the contents of the dish.comments collection from within the details of a single comment. You're likely running into some scope inheritance issue, where you're changing the dish.comments on the child scope, but it is not propagating like you expect to the parent scope.

As to how to fix that... don't use scope inheritance. It's bad, confusing, and often leads to issues like this. You should be storing your comments in a Service which could then centrally be accessed & updated by whatever controllers.

edit: I see you got a better answer on the JavaScript thread. However, I still stand by avoiding usage of scope inheritance. It will lead to heartache in the end.

Skandranon fucked around with this message at 18:09 on Feb 19, 2016

ModeSix
Mar 14, 2009

Skandranon posted:

You shut your mouth!

As to your issue, it looks like you are trying to change the contents of the dish.comments collection from within the details of a single comment. You're likely running into some scope inheritance issue, where you're changing the dish.comments on the child scope, but it is not propagating like you expect to the parent scope.

As to how to fix that... don't use scope inheritance. It's bad, confusing, and often leads to issues like this. You should be storing your comments in a Service which could then centrally be accessed & updated by whatever controllers.

edit: I see you got a better answer on the JavaScript thread. However, I still stand by avoiding usage of scope inheritance. It will lead to heartache in the end.

The suggestions and comments are still welcome. I'm learning this right now so tips like yours are very useful for me.

Right now I have to do it this way because that's what my teacher says, so it may not match the way I'll do it in the real world.

I think he's doing it this way to teach us about inheritance because he made a point to tell us about it several times. We haven't learned about services, injection, routing, etc. etc. yet, we're still working on getting basic scripts working.

ModeSix fucked around with this message at 19:29 on Feb 19, 2016

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

ModeSix posted:

The suggestions and comments are still welcome. I'm learning this right now so tips like yours are very useful for me.

Right now I have to do it this way because that's what my teacher says, so it may not match the way I'll do it in the real world.

I think he's doing it this way to teach us about inheritance because he made a point to tell us about it several times. We haven't learned about services, injection, routing, etc. etc. yet, we're still working on getting basic scripts working.

I'd have to say, I really hate how your teacher is teaching you this then. Angular 1.x has a lot of bad parts in it that really are best forgotten, $scope is one of them. I'd like to believe he is trying to show you how horrible it is so you know never to use it, but I suspect he is teaching how to do things in Angular 1.0 instead of 1.5, which really makes a world of difference. A lot of the tutorials online as well will point to 1.0 type things, and this is one of the reasons Angular catches so much flak. Feel free to ask further questions as you go, or become interested. I could go on for days about (my) best practices.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Skandranon posted:

I'd have to say, I really hate how your teacher is teaching you this then. Angular 1.x has a lot of bad parts in it that really are best forgotten, $scope is one of them. I'd like to believe he is trying to show you how horrible it is so you know never to use it, but I suspect he is teaching how to do things in Angular 1.0 instead of 1.5, which really makes a world of difference. A lot of the tutorials online as well will point to 1.0 type things, and this is one of the reasons Angular catches so much flak. Feel free to ask further questions as you go, or become interested. I could go on for days about (my) best practices.

The official guides go over scope and best practices for how to make a mess with bidirectional transclusions before they even mention components, too, if you go in order. I've been going through them this week to try to get a feel for it because all our potential clients are looking for Angular and I'm not terribly impressed. Like I had to get confused (by the official guide) and go figure out for myself that $scope.prop and this.prop aren't interchangeable in a controller because of how it's declared in the template.

I should probably just buy that book you recommended but I'm afraid I'll just end up mired in 1.0 bullshit wherever I go and end up hating it even more as a result if I do :smith:

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Munkeymon posted:

The official guides go over scope and best practices for how to make a mess with bidirectional transclusions before they even mention components, too, if you go in order. I've been going through them this week to try to get a feel for it because all our potential clients are looking for Angular and I'm not terribly impressed. Like I had to get confused (by the official guide) and go figure out for myself that $scope.prop and this.prop aren't interchangeable in a controller because of how it's declared in the template.

I should probably just buy that book you recommended but I'm afraid I'll just end up mired in 1.0 bullshit wherever I go and end up hating it even more as a result if I do :smith:

If you are going the TypeScript route, and stick to using things like controllerAs or bindToController, you will almost certainly find the right path. Especially if you jump straight to 1.5 and mostly use .component, which basically just always uses controllerAs, bindToController, and isolate scopes.

However, even if you are not using TypeScript and ARE mired in a bunch of awful 1.0 applications, knowing how to do things better gives you a much better idea of how to refactor things to be better, even in a limited area.

Also, ng-book does a good job of explaining how things like scope inheritance, watches, and binding works such that you understand a bit better how and why things work (or don't work).

Summit
Mar 6, 2004

David wanted you to have this.
Pretty much agree with all of this. Angular 1.5 is much more mature and straightforward and will avoid so many headaches. $scope (especially inherited scope wtf) is the way of madness and overly coupled code.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Summit posted:

Pretty much agree with all of this. Angular 1.5 is much more mature and straightforward and will avoid so many headaches. $scope (especially inherited scope wtf) is the way of madness and overly coupled code.

You don't even really need 1.5 to do Angular properly, you can accomplish pretty much everything important in 1.3, which is when they introduced bindToController. Everything after that is just gravy.

ModeSix
Mar 14, 2009

Skandranon posted:

I'd have to say, I really hate how your teacher is teaching you this then. Angular 1.x has a lot of bad parts in it that really are best forgotten, $scope is one of them. I'd like to believe he is trying to show you how horrible it is so you know never to use it, but I suspect he is teaching how to do things in Angular 1.0 instead of 1.5, which really makes a world of difference. A lot of the tutorials online as well will point to 1.0 type things, and this is one of the reasons Angular catches so much flak. Feel free to ask further questions as you go, or become interested. I could go on for days about (my) best practices.

Looks like he has us using 1.4.9.

This Angular course is part of a broader course covering full stack development.

Looking over the next unit in the course it looks like we're going to be looking at Factory, Service, injection, angular templates, ngroute and ui-router, all in the context of SPAs.

I do come from a programming background, so I am sure that once I get a more stable footing in Angular and JS in general I will find leading practices that work better than what we are learning. I will however be frequenting this thread to read and ask questions.

ModeSix fucked around with this message at 03:27 on Feb 20, 2016

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

ModeSix posted:

Looks like he has us using 1.4.9.

This Angular course is part of a broader course covering full stack development.

Looking over the next unit in the course it looks like we're going to be looking at Factory, Service, injection, angular templates, ngroute and ui-router, all in the context of SPAs.

I do come from a programming background, so I am sure that once I get a more stable footing in Angular and JS in general I will find leading practices that work better than what we are learning. I will however be frequenting this thread to read and ask questions.

FFS... well good luck with the course, try not to pick up his bad habits, and if you want to really see how it can be done right, start looking at using it with TypeScript.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Skandranon posted:

If you are going the TypeScript route, and stick to using things like controllerAs or bindToController, you will almost certainly find the right path. Especially if you jump straight to 1.5 and mostly use .component, which basically just always uses controllerAs, bindToController, and isolate scopes.

Yeah, I can see that. I was just trying to point out that there's a lot of, let's say, not-great advice out there, even in the official docs where I'd expect most people to look first. Angular needs to get its poo poo together, basically.

Stoph
Mar 19, 2006

Give a hug - save a life.

Skandranon posted:

You don't even really need 1.5 to do Angular properly, you can accomplish pretty much everything important in 1.3, which is when they introduced bindToController. Everything after that is just gravy.

I'm forced to stay on 1.3 at work and my strategy is to make literally everything a directive with isolate scope and bindToController true.

zorch
Nov 28, 2006

Is there an easy way to figure out which npm module is trying to install node-sass 0.9.6? npm-debug.log doesn't have anything useful, and grep -r "node-sass" . | grep "package.json" yields nothing except for my project's main package.json, which requires node-sass ^3.4.2. Though I suppose the offending package might not show up in node_modules since the node-sass 0.9.6 build is failing. I'm kind of at a loss here and #npm on freenode appears to be dead :smith:

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



zorch posted:

Is there an easy way to figure out which npm module is trying to install node-sass 0.9.6? npm-debug.log doesn't have anything useful, and grep -r "node-sass" . | grep "package.json" yields nothing except for my project's main package.json, which requires node-sass ^3.4.2. Though I suppose the offending package might not show up in node_modules since the node-sass 0.9.6 build is failing. I'm kind of at a loss here and #npm on freenode appears to be dead :smith:

Does " npm ls" give you anything useful? It should print the complete trees of dependencies for whatever is installed.

zorch
Nov 28, 2006

piratepilates posted:

Does " npm ls" give you anything useful? It should print the complete trees of dependencies for whatever is installed.

The only reference to node-sass in the tree view is for 3.4.2. Here are the trees.

abraham linksys
Sep 6, 2010

:darksouls:
npm install --verbose might give you enough output to help you debug this. also worth trying an `npm cache clean && rm -rf node_modules/`, sometimes you can end up with weird cached or local dependencies that are no longer actually used

zorch
Nov 28, 2006

welp, harp init set an ancient version of harp in package.json -- 0.13.0, which is 18 months old. that had something to do with it :suicide:

ModeSix
Mar 14, 2009

Skandranon posted:

FFS... well good luck with the course, try not to pick up his bad habits, and if you want to really see how it can be done right, start looking at using it with TypeScript.

Could you point me towards some resources that will show me how to accomplish what I am doing without using $scope?

I looked at the TypeScript documentation and it looks like greek to me at this point, it's something I'll have to figure out eventually though I'm sure.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



ModeSix posted:

Could you point me towards some resources that will show me how to accomplish what I am doing without using $scope?

I looked at the TypeScript documentation and it looks like greek to me at this point, it's something I'll have to figure out eventually though I'm sure.

It's my understanding that https://docs.angularjs.org/guide/component are The Way of the Future in Angular, but it looks like they're not present in 1.4x?

Flat Daddy
Dec 3, 2014

by Nyc_Tattoo

Munkeymon posted:

It's my understanding that https://docs.angularjs.org/guide/component are The Way of the Future in Angular, but it looks like they're not present in 1.4x?

I haven't tried it but for 1.3 and 1.4 you could use this backport: https://github.com/toddmotto/angular-component, since they're just a small bit of sugar over directives anyway.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Flat Daddy posted:

I haven't tried it but for 1.3 and 1.4 you could use this backport: https://github.com/toddmotto/angular-component, since they're just a small bit of sugar over directives anyway.

Ah, I was wondering why components looked so familiar.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Munkeymon posted:

Ah, I was wondering why components looked so familiar.

You can accomplish what a component is simply by using bindToController, controllerAs, and scope {}

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Has anyone here worked with Vue.js? I came across it while job searching and it looks like a pretty capable library, almost like a more streamlined (simplified?) AngularJS with an emphasis on React-esque components.

ModeSix
Mar 14, 2009

Munkeymon posted:

It's my understanding that https://docs.angularjs.org/guide/component are The Way of the Future in Angular, but it looks like they're not present in 1.4x?

I updated my Angular version to 1.5.0 as recommended in this thread. :v:

ModeSix
Mar 14, 2009

So next newbie question.

I'm trying to use a controller to return a value from an array that is in a factory.

I really feel out of my depth with this one as it wasn't really explained in the class how to do this.

I've tried a lot of different things and nothing seems to work.

In my controller I can get this to return the complete item that is stored in the array at position [0], including all sub-data that is with it.

code:
        .controller('IndexController', ['$scope', 'menuFactory', 'corporateFactory', function($scope, menuFactory, corporateFactory) {

            // How can I get this let me choose the item number through the html by using: {{item(0)}}
            var featuredItem = menuFactory.getDish(parseInt(0, 10)); 
            
	    $scope.featuredItem = featuredItem;
            
        }])
Using:
code:
<div ng-repeat="item in featuredItem">
	{{item}} // This doesn't work at all if I use {{item.name}} even though name is a sub-item of the item.
</div>
What I cannot do is access the sub-items example {{item.name}}.

Also I can't figure out how to for example grab {{item(1)}} instead of what I've predefined in the controller (item 0). Extending this to {{item(1).name}} of course.

I've been beating my head against this all day and really can't figure it out.

Can someone please explain to me how to do this or point me to an example that would be easily understood by a beginner.

I've used the factory/service code for other things, so I know it returns the correct data.

And I know $scope is terrible, but I don't know another way to do it (yet).

ModeSix fucked around with this message at 20:19 on Feb 24, 2016

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

ModeSix posted:

So next newbie question.

I'm trying to use a controller to return a value from an array that is in a factory.

I really feel out of my depth with this one as it wasn't really explained in the class how to do this.

I've tried a lot of different things and nothing seems to work.

In my controller I can get this to return the complete item that is stored in the array at position [0], including all sub-data that is with it.

code:
        .controller('IndexController', ['$scope', 'menuFactory', 'corporateFactory', function($scope, menuFactory, corporateFactory) {

            // How can I get this let me choose the item number through the html by using: {{item(0)}}
            var featuredItem = menuFactory.getDish(parseInt(0, 10)); 
            
	    $scope.featuredItem = featuredItem;
            
        }])
Using:
code:
<div ng-repeat="item in featuredItem">
	{{item}} // This doesn't work at all if I use {{item.name}} even though name is a sub-item of the item.
</div>
What I cannot do is access the sub-items example {{item.name}}.

Also I can't figure out how to for example grab {{item(1)}} instead of what I've predefined in the controller (item 0). Extending this to {{item(1).name}} of course.

I've been beating my head against this all day and really can't figure it out.

Can someone please explain to me how to do this or point me to an example that would be easily understood by a beginner.

I've used the factory/service code for other things, so I know it returns the correct data.

And I know $scope is terrible, but I don't know another way to do it (yet).

What DOES show up from {{item}}? What is featuredItem supposed to be?

ModeSix
Mar 14, 2009

I figured it out, have to do it differently than I wanted to, but I figured it out.

ModeSix fucked around with this message at 20:59 on Feb 24, 2016

HaB
Jan 5, 2001

What are the odds?

ModeSix posted:

So next newbie question.

I'm trying to use a controller to return a value from an array that is in a factory.

I really feel out of my depth with this one as it wasn't really explained in the class how to do this.

I've tried a lot of different things and nothing seems to work.

In my controller I can get this to return the complete item that is stored in the array at position [0], including all sub-data that is with it.

code:
        .controller('IndexController', ['$scope', 'menuFactory', 'corporateFactory', function($scope, menuFactory, corporateFactory) {

            // How can I get this let me choose the item number through the html by using: {{item(0)}}
            var featuredItem = menuFactory.getDish(parseInt(0, 10)); 
            
	    $scope.featuredItem = featuredItem;
            
        }])
Using:
code:
<div ng-repeat="item in featuredItem">
	{{item}} // This doesn't work at all if I use {{item.name}} even though name is a sub-item of the item.
</div>
What I cannot do is access the sub-items example {{item.name}}.

Also I can't figure out how to for example grab {{item(1)}} instead of what I've predefined in the controller (item 0). Extending this to {{item(1).name}} of course.

I've been beating my head against this all day and really can't figure it out.

Can someone please explain to me how to do this or point me to an example that would be easily understood by a beginner.

I've used the factory/service code for other things, so I know it returns the correct data.

And I know $scope is terrible, but I don't know another way to do it (yet).

I see as I went to answer you had figured it out - but why would you name it 'featuredItem' if it is an array?

By extension - why does a function called getDish return an array?

ModeSix
Mar 14, 2009

HaB posted:

I see as I went to answer you had figured it out - but why would you name it 'featuredItem' if it is an array?

By extension - why does a function called getDish return an array?

It returns the dish(es) array which contains all the dishes.

I always forget I can access the controller directly.

{{featuredItem[3].name}} etc. works the trick.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

ModeSix posted:

It returns the dish(es) array which contains all the dishes.

I always forget I can access the controller directly.

{{featuredItem[3].name}} etc. works the trick.

I know I often sound like a boring, unfun old man, but this is bad. You should strive to keep such implementation details out of your HTML. One of Angular's big mistakes is the "ToDo app with NO CODE". Of course there is code, it's just implicit in the HTML, which leads to big problems for anything real.

If item 3 is special, you should probably extract it to a specific variable. If you are trying to show all the items, you should iterate over the collection.

In general, your templates should contain a minimum of logic, and just reference properties in your controller. Your controller is responsible for preparing such properties for the template. Services should be used to store any data that is not ONLY for display purposes.

Skandranon fucked around with this message at 21:51 on Feb 24, 2016

Adbot
ADBOT LOVES YOU

HaB
Jan 5, 2001

What are the odds?

ModeSix posted:

It returns the dish(es) array which contains all the dishes.

I always forget I can access the controller directly.

{{featuredItem[3].name}} etc. works the trick.

K. That's completely unclear as a third party reading your code.

If getDish returns an array, name it getDishes

It seems small and nitpicky but little stuff like that will drive you insane down the road. Cultivate those habits now and you won't have to worry about it.

See also everything Skandranon just said.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply