mainData in AngularJS

 <tr ng-hide="mainData.selectedTrade.ID === '4' || mainData.selectedTrade.ID === '5'">

Open in new window


Does mainData have some special meaning in angular?

I don't see it "declared" anywhere.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
No, it doesn't.
Does that <tr> ever disappear?

mainData is a scope variable and is either missing which in that case won't do anything, or is being set in the HTML or in one controller.
Be aware that scope inheritance exists in AngularJS so this scope variable may be coming from a higher level controller.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tom KnowltonWeb developerAuthor Commented:
It was just an example from the code -- I've not tested it to see if it works or doesn't.

Based on what I see happening elsewhere -- it seems to be missing.  A global search through my source does not show it listed as other scope variables seem to be:

onlineApp.controller('confirmationReportController', ['$scope', '$rootScope', '$sce','$http', function ($scope, $rootScope, $sce, $http) {
 
 Perhaps the developer who began writing that portion intended to pass it in for injection and just hasn't yet.  He's offsite but I'll contact him about this.

So the fix would be:

onlineApp.controller('confirmationReportController', ['$scope', '$rootScope', '$sce','$http', '$mainData', function ($scope, $rootScope, $sce, $http, $mainData) {
 

Right?

Thanks!

Tom
0
Tom KnowltonWeb developerAuthor Commented:
Great job.
0
Alexandre SimõesManager / Technology SpecialistCommented:
Actually the fix is not that and it's almost certain to throw an $injector error.

The code expects this to exist: mainData.selectedTrade.ID
So you need a mainData variable in the scope that had a property selectedTrade that in turn as a property ID.
Something like:
$scope.mainData = {
  selectedTrade : {
    ID: '4'
  }
};

Open in new window

With this code in your controller the <tr> element should disappear.
0
Tom KnowltonWeb developerAuthor Commented:
Thank you ... I'll make sure this happens.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.