These are chat archives for angular/angular.js

14th
Jan 2017
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:35
@frederikprijck hey, I need help. so, i read a little bit on angular js and watched a few videos on pluralsight. I have been able to store the data of my form, but I can't log it to my console.
Frederik Prijck
@frederikprijck
Jan 14 2017 14:36
console.log works. So dus $log.debug
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:36
app.controller("FormCtrl", ["$scope", "$location", "$window", "dataService", function($scope, $location, $window, dataService) {

    $scope.newuser = dataService.details;
    $scope.submit = function() {
      dataService.submitInfo();
    }

       if(document.getElementById('showPswd')) {
      document.getElementById('showPswd').addEventListener("click", function() {
          var pwd = document.getElementById("newPassword");
          if (pwd.getAttribute("type") === "password") {
              pwd.setAttribute("type", "text");
          } else {
              pwd.setAttribute("type", "password");
          }
      });
    }
    if(document.getElementById('last')) {
      console.log(dataService.newuser);
          setTimeout(function() {
            $window.open('http://www.ayushdevelops.com/');
          }, 10000);
    }

    $scope.go = function(path) {
      $location.path(path);
    };
}]);

app.service('dataService', function() {
  var userData = this;
  userData.details = {
    "firstname": '',
    "lastname": '',
    "email": '',
    "number": '',
    "password": '',
    "aadhar": '',
    "pan": ''
  }
  userData.submitInfo = function(){
    console.log(userData.details.firstname);
  }
})
Frederik Prijck
@frederikprijck
Jan 14 2017 14:36
You dont want code like this in ur controller: if(document.getElementById('showPswd'))
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:39
well, i am seeing undefined in my console. however the dataService.details is storing values, without loosing them when a new view enters.
Frederik Prijck
@frederikprijck
Jan 14 2017 14:39
console.log(dataService.newuser); this will log undefined
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:39
where should I put it then?
Frederik Prijck
@frederikprijck
Jan 14 2017 14:40
can u change it to: console.log(dataService.details);
That will give you the result.
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:41
I don't have console.log(dataService.newuser) in my code
Frederik Prijck
@frederikprijck
Jan 14 2017 14:41
You do.
Atleast I see it in the code you showed me.
blob
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:42
oh no. I didn' t see that. I am so sorry. i must have forgot to remove that. I had this in my service console.log(userData.details.firstname);
Frederik Prijck
@frederikprijck
Jan 14 2017 14:42
But that's not loggin undefined, is it ?
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:43
it is logging undefined. Let me try again though, I had just one thing logged in my console. that's undefined, let me try again give me a min
Frederik Prijck
@frederikprijck
Jan 14 2017 14:44
If it is, create a plunkr. I can't help you without one.
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:46
now it is logging nothing.
the problem with creating a plunkr is that it is a form, and you'd have to enter data into it. Last time we went through that, you didn't like it
my dataService.details is storing data correctly. because i have inserted data binding expressions in each view, and as I can see it stores the data correctly. I am calling the submit function through ng-click on the final section.
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:52
the main problem is that i don't see any error either.
Frederik Prijck
@frederikprijck
Jan 14 2017 14:53
@relentless-coder I don't mind a form in a plunkr, I just dont like a 5 step form with a bug in the last step making me submit each step before I can test the problem.
now it is logging nothing.
You mean an empty string ? Or ?
Ayush Bahuguna
@relentless-coder
Jan 14 2017 14:54
well that's what the situation is. it is probably in the last section.
nothing. white blank
Frederik Prijck
@frederikprijck
Jan 14 2017 14:54
So it went from logging undefined to logging blank, I would say that's better already .
Could you try this:
console.log(userData); in your submitInfo method instead of console.log(userData.details.firstname);
well that's what the situation is. it is probably in the last section.
The main thing to do if you want to get help, is strip everything away from your application in such away that only the parts relevant to the problem are in the plunkr.
80% of the time you might even discover the cause of the problem yourself this way. (And this is realy going to help you in understanding what's happening aswell as helping you to debug your problems)

But I can't force you to do so, but beside changing the log statement to what I said :

console.log(userData); in your submitInfo method instead of console.log(userData.details.firstname);

I can't realy help you without seeing the problem.

Ayush Bahuguna
@relentless-coder
Jan 14 2017 15:02
i completely understand your concern

this is the submit code in the last view.

<input type="submit" ng-show="newuser.aadhar && newuser.pan" ng-click="submit()" name="submit-info" value="Submit" id="submit">

is this correct?

Frederik Prijck
@frederikprijck
Jan 14 2017 15:03
Looking at your controller, I'd say it is.
But have you changed what I asked you to change ?
console.log(userData); in your submitInfo method instead of console.log(userData.details.firstname);
If yes, what's it outputting ?
Ayush Bahuguna
@relentless-coder
Jan 14 2017 15:04
yes, it is still white blank
Frederik Prijck
@frederikprijck
Jan 14 2017 15:05
Can you check which line is making it blank ?
I'd say it's this: console.log(dataService.newuser);
But it's almost impossible that both console.log(userData.details.firstname) and console.log(userData) log blank.
Ayush Bahuguna
@relentless-coder
Jan 14 2017 15:05
i have removed that line
wasn't console.log(userData) supposed to give error?
Frederik Prijck
@frederikprijck
Jan 14 2017 15:05
No, atleast not for as far as I know what your app is doing.
Anyway, this is leading nowhere. Create a plunkr, even with your 5 steps form and I will look at it for you.
But you should realy put some effort in reproducing the problem in a plunkr instead of putting your entire application in a plunkr :( (it realy is going to help yourself aswell! )
Ayush Bahuguna
@relentless-coder
Jan 14 2017 15:08
that's what I am doing, don't worry, I'll shorten my form. let me try putting in just two views, first i'll try that, then let you see it
Frederik Prijck
@frederikprijck
Jan 14 2017 15:09
Thanks @relentless-coder ! :D
Ahmed Rebai
@Rebaiahmed
Jan 14 2017 21:29
anyone want ot create open source project with angular ?
Frederik Prijck
@frederikprijck
Jan 14 2017 21:47
@jump020305 That's not Angular, is it ? :scream:
Ahmed Rebai
@Rebaiahmed
Jan 14 2017 21:48
@frederikprijck :shipit:
Frederik Prijck
@frederikprijck
Jan 14 2017 21:49
What's up @Rebaiahmed ?
Amir Sharif
@hmamirchishti
Jan 14 2017 21:51
I created an app using CLI, but its running in production mode...
How can I enable it to dev mode?
Frederik Prijck
@frederikprijck
Jan 14 2017 21:52
but generally you just don't call enableProdMode(); IIRC
Ahmed Rebai
@Rebaiahmed
Jan 14 2017 21:53
@hmamirchishti ng new subject to speak about it ;)
Amir Sharif
@hmamirchishti
Jan 14 2017 21:53
@frederikprijck I commntd it. but still facing the same
Frederik Prijck
@frederikprijck
Jan 14 2017 21:55
Well, I guess people at the angular 2 channel will be able to help u :)
Amir Sharif
@hmamirchishti
Jan 14 2017 21:55
thank you @frederikprijck
Ahmed Rebai
@Rebaiahmed
Jan 14 2017 21:56
:clap: