angularjs ng-click function not working

the click event
  <a href="#" ng-click="myNum(l.GroupID)">{{l.Desc}}</a>

Open in new window

I need it to change the value
 $scope.mypage = 1;  // Need to change here and submit.
                                               
                                              $scope.myNum = function (num) {

                                                   $scope.mypage = num;
                                                   alert($scope.mypage);
                                                   $scope.todo.items.push({GroupID: num, done: false });
                                         
                                               }

Open in new window

so if you was to change  $scope.mypage = 1 to  $scope.mypage = 2 you see the table change.



http://plnkr.co/edit/bptVckBXQC72anPGzDmR?p=preview
LVL 9
Seven priceFull StackAsked:
Who is Participating?
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.

Ioannis ParaskevopoulosCommented:
Hi,

Your ng-click works fine and that is shown by the alert firing when you click on the links. What is not correct is your filter in the ng-repeat.

Change that:
<tr ng-repeat="q in myData | filter:q.GroupID">

Open in new window


to:
<tr ng-repeat="q in myData | filter:{GroupID:mypage}">

Open in new window


In your way you say "filter on GroupID" but filter on what value? You do not give any hint on what value to filter on. Another common mistake is the use of "q.". You are filtering the array not the object and q points to the objects in the array.

Giannis
0
Seven priceFull StackAuthor Commented:
Ok so how can I use the ng show to filter by ng click . I want to pass the value to ng show from the ng click.  Also thanks
0
Seven priceFull StackAuthor Commented:
oh that was great. ok. the rest of the form that is not showing up. Is there a way to hold the values when I click to another page. so if I put something in the text box click on link and then go back can I get it to keep the input value I entered.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Ioannis ParaskevopoulosCommented:
Hi,

I am away frim a pc, but if i remember well your code, yes on both questions. I will have to answer tomorrow though.

Giannis
0
Seven priceFull StackAuthor Commented:
Ok great. Thanks again.
0
Ioannis ParaskevopoulosCommented:
Hi,

First of all, i removed the ng-show as they were useless if you use the filter as discussed yesterday. So, i created a fork of your plunker with my changes here.

The changes are:

1. Reoved some links for brevity.

2. Removed ng-show directives from the tds.

3. Added fake model binding.

<input type="text" id="{{$index + 1}}" ng-model="q.answer" />

Open in new window


What i did on step 3 was adding ng-model directive on the input. I just added 'q.answer' to the ng-model. This when filled in, will add a property to the changed question object and fill the value of the changed input.

Try it out. It is so simple that Angular does most of the job for you.

Giannis
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
Seven priceFull StackAuthor Commented:
thanks again.
0
Seven priceFull StackAuthor Commented:
have a quick question and this is goes with why i use ng-show. how can i get all the values if I am filtering the form
0
Ioannis ParaskevopoulosCommented:
I do not quite understand the question. You are filtering the view not the values.
0
Seven priceFull StackAuthor Commented:
I know but how can I retrieve the values on one submit. or should I change everything to and she show where everything is hidden in the dom but I could still retrieve all the values
0
Seven priceFull StackAuthor Commented:
Sorry I was driving. I want to retrieve all the values and submit them at once. I know I am filtering. i was wondering does angularjs hold the values in the ng-model and I can submit them at once.
0
Seven priceFull StackAuthor Commented:
I open another comment so you can retrieve the points. Thanks again.

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28627780.html
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
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.