TS2304: Cannot find name











up vote
0
down vote

favorite












HI there guy's i'm relatively new on Typescript and Angular and i try figure out in this case: i got the erro below error on ng build, but in ng serve everything going well.. Whats strange issue is this. Also i want to make some declaration privete but with private doesen't work. Need to understand more some tricks probably...



TS2304: Cannot find name 'ngRedux'.



import { Component, OnInit, AfterViewChecked, OnDestroy, ViewEncapsulation} from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { MatDialog } from '@angular/material';
import { Http, Response, RequestOptions, Headers } from '@angular/http';
import { PayPalConfig, PayPalEnvironment, PayPalIntegrationType } from 'ngx-paypal';
import { MatRadioChange } from '@angular/material';
import { CookieService } from 'ngx-cookie-service';
import { UsersProvider} from '../../../../../providers/users.provider';
import { NgRedux } from '@angular-redux/store';
import {IAppState} from '../../../../../reducers';


declare let paypal: any;
@Component({
selector : 'abbonamento',
templateUrl : './abbonamento.component.html',
styleUrls : ['./abbonamento.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class AbbonamentoComponent implements OnInit, OnDestroy, AfterViewChecked
{
addScript: boolean = false;
paypalLoad: boolean = true;
public finalAmount: number = 1;
abbonamenti = ;
caratteristiche = ;
public PayPalConfig?: PayPalConfig;
constructor(
public http: Http,
public cookieService: CookieService,
public ngRedux: NgRedux<IAppState>,
)
{

}

ngOnInit()
{
this.http.get('https://dev.site.it/get-abbonamenti').map(res => res.json()).subscribe(data => {
this.abbonamenti = data.abbonamenti;
this.caratteristiche = data.caratteristiche;
});
}

ngOnDestroy()
{
}


payPalConfig = {
env: 'sandbox',
client: {
sandbox: 'xxxxxxxxxxxxxxxxxxx',
production: 'xxxxxxxxxxxxxxxxxxxxx'
},
commit: true,

// payment() is called when the button is clicked
payment: function (data, actions) {
// Make a call to the REST api to create the payment
let prezzo = cookieService.get('importo');
return actions.payment.create({
payment: {
transactions: [
{
amount: {total: prezzo, currency: 'EUR'}
}
]

}
})
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function (data, actions) {

// Make a call to the REST api to execute the payment
return actions.payment.execute().then((response) => {
console.log(response);
var data = {
user_id: ngRedux.getState().session,
dati_transazione: response,
}
http.post('https://dev.sito.it/aggiorna-abbonamento', data).subscribe(data=> {});
window.alert('Pagamento confermato');
});
}
}

pianoChange(event: MatRadioChange)
{
this.cookieService.set( 'importo', event.value );
}


ngAfterViewChecked(): void {
if (!this.addScript) {
this.addPaypalScript().then(() => {
paypal.Button.render(this.payPalConfig, '#paypal-checkout-btn');
this.paypalLoad = false;
})
}
}

addPaypalScript() {
this.addScript = true;
return new Promise((resolve, reject) => {
let scripttagElement = document.createElement('script');
scripttagElement.src = 'https://www.paypalobjects.com/api/checkout.js';
scripttagElement.onload = resolve;
document.body.appendChild(scripttagElement);
})
}

}









share|improve this question


























    up vote
    0
    down vote

    favorite












    HI there guy's i'm relatively new on Typescript and Angular and i try figure out in this case: i got the erro below error on ng build, but in ng serve everything going well.. Whats strange issue is this. Also i want to make some declaration privete but with private doesen't work. Need to understand more some tricks probably...



    TS2304: Cannot find name 'ngRedux'.



    import { Component, OnInit, AfterViewChecked, OnDestroy, ViewEncapsulation} from '@angular/core';
    import { Subscription } from 'rxjs/Subscription';
    import { MatDialog } from '@angular/material';
    import { Http, Response, RequestOptions, Headers } from '@angular/http';
    import { PayPalConfig, PayPalEnvironment, PayPalIntegrationType } from 'ngx-paypal';
    import { MatRadioChange } from '@angular/material';
    import { CookieService } from 'ngx-cookie-service';
    import { UsersProvider} from '../../../../../providers/users.provider';
    import { NgRedux } from '@angular-redux/store';
    import {IAppState} from '../../../../../reducers';


    declare let paypal: any;
    @Component({
    selector : 'abbonamento',
    templateUrl : './abbonamento.component.html',
    styleUrls : ['./abbonamento.component.scss'],
    encapsulation: ViewEncapsulation.None
    })
    export class AbbonamentoComponent implements OnInit, OnDestroy, AfterViewChecked
    {
    addScript: boolean = false;
    paypalLoad: boolean = true;
    public finalAmount: number = 1;
    abbonamenti = ;
    caratteristiche = ;
    public PayPalConfig?: PayPalConfig;
    constructor(
    public http: Http,
    public cookieService: CookieService,
    public ngRedux: NgRedux<IAppState>,
    )
    {

    }

    ngOnInit()
    {
    this.http.get('https://dev.site.it/get-abbonamenti').map(res => res.json()).subscribe(data => {
    this.abbonamenti = data.abbonamenti;
    this.caratteristiche = data.caratteristiche;
    });
    }

    ngOnDestroy()
    {
    }


    payPalConfig = {
    env: 'sandbox',
    client: {
    sandbox: 'xxxxxxxxxxxxxxxxxxx',
    production: 'xxxxxxxxxxxxxxxxxxxxx'
    },
    commit: true,

    // payment() is called when the button is clicked
    payment: function (data, actions) {
    // Make a call to the REST api to create the payment
    let prezzo = cookieService.get('importo');
    return actions.payment.create({
    payment: {
    transactions: [
    {
    amount: {total: prezzo, currency: 'EUR'}
    }
    ]

    }
    })
    },
    // onAuthorize() is called when the buyer approves the payment
    onAuthorize: function (data, actions) {

    // Make a call to the REST api to execute the payment
    return actions.payment.execute().then((response) => {
    console.log(response);
    var data = {
    user_id: ngRedux.getState().session,
    dati_transazione: response,
    }
    http.post('https://dev.sito.it/aggiorna-abbonamento', data).subscribe(data=> {});
    window.alert('Pagamento confermato');
    });
    }
    }

    pianoChange(event: MatRadioChange)
    {
    this.cookieService.set( 'importo', event.value );
    }


    ngAfterViewChecked(): void {
    if (!this.addScript) {
    this.addPaypalScript().then(() => {
    paypal.Button.render(this.payPalConfig, '#paypal-checkout-btn');
    this.paypalLoad = false;
    })
    }
    }

    addPaypalScript() {
    this.addScript = true;
    return new Promise((resolve, reject) => {
    let scripttagElement = document.createElement('script');
    scripttagElement.src = 'https://www.paypalobjects.com/api/checkout.js';
    scripttagElement.onload = resolve;
    document.body.appendChild(scripttagElement);
    })
    }

    }









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      HI there guy's i'm relatively new on Typescript and Angular and i try figure out in this case: i got the erro below error on ng build, but in ng serve everything going well.. Whats strange issue is this. Also i want to make some declaration privete but with private doesen't work. Need to understand more some tricks probably...



      TS2304: Cannot find name 'ngRedux'.



      import { Component, OnInit, AfterViewChecked, OnDestroy, ViewEncapsulation} from '@angular/core';
      import { Subscription } from 'rxjs/Subscription';
      import { MatDialog } from '@angular/material';
      import { Http, Response, RequestOptions, Headers } from '@angular/http';
      import { PayPalConfig, PayPalEnvironment, PayPalIntegrationType } from 'ngx-paypal';
      import { MatRadioChange } from '@angular/material';
      import { CookieService } from 'ngx-cookie-service';
      import { UsersProvider} from '../../../../../providers/users.provider';
      import { NgRedux } from '@angular-redux/store';
      import {IAppState} from '../../../../../reducers';


      declare let paypal: any;
      @Component({
      selector : 'abbonamento',
      templateUrl : './abbonamento.component.html',
      styleUrls : ['./abbonamento.component.scss'],
      encapsulation: ViewEncapsulation.None
      })
      export class AbbonamentoComponent implements OnInit, OnDestroy, AfterViewChecked
      {
      addScript: boolean = false;
      paypalLoad: boolean = true;
      public finalAmount: number = 1;
      abbonamenti = ;
      caratteristiche = ;
      public PayPalConfig?: PayPalConfig;
      constructor(
      public http: Http,
      public cookieService: CookieService,
      public ngRedux: NgRedux<IAppState>,
      )
      {

      }

      ngOnInit()
      {
      this.http.get('https://dev.site.it/get-abbonamenti').map(res => res.json()).subscribe(data => {
      this.abbonamenti = data.abbonamenti;
      this.caratteristiche = data.caratteristiche;
      });
      }

      ngOnDestroy()
      {
      }


      payPalConfig = {
      env: 'sandbox',
      client: {
      sandbox: 'xxxxxxxxxxxxxxxxxxx',
      production: 'xxxxxxxxxxxxxxxxxxxxx'
      },
      commit: true,

      // payment() is called when the button is clicked
      payment: function (data, actions) {
      // Make a call to the REST api to create the payment
      let prezzo = cookieService.get('importo');
      return actions.payment.create({
      payment: {
      transactions: [
      {
      amount: {total: prezzo, currency: 'EUR'}
      }
      ]

      }
      })
      },
      // onAuthorize() is called when the buyer approves the payment
      onAuthorize: function (data, actions) {

      // Make a call to the REST api to execute the payment
      return actions.payment.execute().then((response) => {
      console.log(response);
      var data = {
      user_id: ngRedux.getState().session,
      dati_transazione: response,
      }
      http.post('https://dev.sito.it/aggiorna-abbonamento', data).subscribe(data=> {});
      window.alert('Pagamento confermato');
      });
      }
      }

      pianoChange(event: MatRadioChange)
      {
      this.cookieService.set( 'importo', event.value );
      }


      ngAfterViewChecked(): void {
      if (!this.addScript) {
      this.addPaypalScript().then(() => {
      paypal.Button.render(this.payPalConfig, '#paypal-checkout-btn');
      this.paypalLoad = false;
      })
      }
      }

      addPaypalScript() {
      this.addScript = true;
      return new Promise((resolve, reject) => {
      let scripttagElement = document.createElement('script');
      scripttagElement.src = 'https://www.paypalobjects.com/api/checkout.js';
      scripttagElement.onload = resolve;
      document.body.appendChild(scripttagElement);
      })
      }

      }









      share|improve this question













      HI there guy's i'm relatively new on Typescript and Angular and i try figure out in this case: i got the erro below error on ng build, but in ng serve everything going well.. Whats strange issue is this. Also i want to make some declaration privete but with private doesen't work. Need to understand more some tricks probably...



      TS2304: Cannot find name 'ngRedux'.



      import { Component, OnInit, AfterViewChecked, OnDestroy, ViewEncapsulation} from '@angular/core';
      import { Subscription } from 'rxjs/Subscription';
      import { MatDialog } from '@angular/material';
      import { Http, Response, RequestOptions, Headers } from '@angular/http';
      import { PayPalConfig, PayPalEnvironment, PayPalIntegrationType } from 'ngx-paypal';
      import { MatRadioChange } from '@angular/material';
      import { CookieService } from 'ngx-cookie-service';
      import { UsersProvider} from '../../../../../providers/users.provider';
      import { NgRedux } from '@angular-redux/store';
      import {IAppState} from '../../../../../reducers';


      declare let paypal: any;
      @Component({
      selector : 'abbonamento',
      templateUrl : './abbonamento.component.html',
      styleUrls : ['./abbonamento.component.scss'],
      encapsulation: ViewEncapsulation.None
      })
      export class AbbonamentoComponent implements OnInit, OnDestroy, AfterViewChecked
      {
      addScript: boolean = false;
      paypalLoad: boolean = true;
      public finalAmount: number = 1;
      abbonamenti = ;
      caratteristiche = ;
      public PayPalConfig?: PayPalConfig;
      constructor(
      public http: Http,
      public cookieService: CookieService,
      public ngRedux: NgRedux<IAppState>,
      )
      {

      }

      ngOnInit()
      {
      this.http.get('https://dev.site.it/get-abbonamenti').map(res => res.json()).subscribe(data => {
      this.abbonamenti = data.abbonamenti;
      this.caratteristiche = data.caratteristiche;
      });
      }

      ngOnDestroy()
      {
      }


      payPalConfig = {
      env: 'sandbox',
      client: {
      sandbox: 'xxxxxxxxxxxxxxxxxxx',
      production: 'xxxxxxxxxxxxxxxxxxxxx'
      },
      commit: true,

      // payment() is called when the button is clicked
      payment: function (data, actions) {
      // Make a call to the REST api to create the payment
      let prezzo = cookieService.get('importo');
      return actions.payment.create({
      payment: {
      transactions: [
      {
      amount: {total: prezzo, currency: 'EUR'}
      }
      ]

      }
      })
      },
      // onAuthorize() is called when the buyer approves the payment
      onAuthorize: function (data, actions) {

      // Make a call to the REST api to execute the payment
      return actions.payment.execute().then((response) => {
      console.log(response);
      var data = {
      user_id: ngRedux.getState().session,
      dati_transazione: response,
      }
      http.post('https://dev.sito.it/aggiorna-abbonamento', data).subscribe(data=> {});
      window.alert('Pagamento confermato');
      });
      }
      }

      pianoChange(event: MatRadioChange)
      {
      this.cookieService.set( 'importo', event.value );
      }


      ngAfterViewChecked(): void {
      if (!this.addScript) {
      this.addPaypalScript().then(() => {
      paypal.Button.render(this.payPalConfig, '#paypal-checkout-btn');
      this.paypalLoad = false;
      })
      }
      }

      addPaypalScript() {
      this.addScript = true;
      return new Promise((resolve, reject) => {
      let scripttagElement = document.createElement('script');
      scripttagElement.src = 'https://www.paypalobjects.com/api/checkout.js';
      scripttagElement.onload = resolve;
      document.body.appendChild(scripttagElement);
      })
      }

      }






      angular typescript angular5






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 at 13:30









      wwhitewalter

      137




      137
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          That's because you might have some variables declared as private but which are still being used in the template of a particular component.



          The way around this is to make all those properties that you will be using in the template as public and the rest and private. Doing this should fix the issue for you.



          The overall idea here is, if you want to use anything from a file outside that file, you'll have to declare it as public otherwise you're going to get errors while building.






          share|improve this answer





















          • how i can to this?
            – wwhitewalter
            Nov 19 at 14:01


















          up vote
          0
          down vote













          Search for this line of the onAuthorize() function:



                user_id: ngRedux.getState().session,


          Change it to this:



                user_id: this.ngRedux.getState().session,


          You are accessing a class variable not a function local variable, so you need to specify the this keyword.



          All this assumes that you have the @angular-redux library property installed as part of your project and that the NgRedux<IAppState> is set up as a provider in your @NgModule.






          share|improve this answer





















          • I got this error now: Cannot read property 'getState' of undefined
            – wwhitewalter
            Nov 19 at 14:00










          • That makes me think that your ngRedux class is not set up as an injectable provider. I don't know anything about the angular-redux library, but be sure you are setting it up as a provider in the current application.
            – JeffryHouser
            Nov 20 at 13:35











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375713%2fts2304-cannot-find-name%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          That's because you might have some variables declared as private but which are still being used in the template of a particular component.



          The way around this is to make all those properties that you will be using in the template as public and the rest and private. Doing this should fix the issue for you.



          The overall idea here is, if you want to use anything from a file outside that file, you'll have to declare it as public otherwise you're going to get errors while building.






          share|improve this answer





















          • how i can to this?
            – wwhitewalter
            Nov 19 at 14:01















          up vote
          0
          down vote













          That's because you might have some variables declared as private but which are still being used in the template of a particular component.



          The way around this is to make all those properties that you will be using in the template as public and the rest and private. Doing this should fix the issue for you.



          The overall idea here is, if you want to use anything from a file outside that file, you'll have to declare it as public otherwise you're going to get errors while building.






          share|improve this answer





















          • how i can to this?
            – wwhitewalter
            Nov 19 at 14:01













          up vote
          0
          down vote










          up vote
          0
          down vote









          That's because you might have some variables declared as private but which are still being used in the template of a particular component.



          The way around this is to make all those properties that you will be using in the template as public and the rest and private. Doing this should fix the issue for you.



          The overall idea here is, if you want to use anything from a file outside that file, you'll have to declare it as public otherwise you're going to get errors while building.






          share|improve this answer












          That's because you might have some variables declared as private but which are still being used in the template of a particular component.



          The way around this is to make all those properties that you will be using in the template as public and the rest and private. Doing this should fix the issue for you.



          The overall idea here is, if you want to use anything from a file outside that file, you'll have to declare it as public otherwise you're going to get errors while building.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 13:33









          SiddAjmera

          11.7k21137




          11.7k21137












          • how i can to this?
            – wwhitewalter
            Nov 19 at 14:01


















          • how i can to this?
            – wwhitewalter
            Nov 19 at 14:01
















          how i can to this?
          – wwhitewalter
          Nov 19 at 14:01




          how i can to this?
          – wwhitewalter
          Nov 19 at 14:01












          up vote
          0
          down vote













          Search for this line of the onAuthorize() function:



                user_id: ngRedux.getState().session,


          Change it to this:



                user_id: this.ngRedux.getState().session,


          You are accessing a class variable not a function local variable, so you need to specify the this keyword.



          All this assumes that you have the @angular-redux library property installed as part of your project and that the NgRedux<IAppState> is set up as a provider in your @NgModule.






          share|improve this answer





















          • I got this error now: Cannot read property 'getState' of undefined
            – wwhitewalter
            Nov 19 at 14:00










          • That makes me think that your ngRedux class is not set up as an injectable provider. I don't know anything about the angular-redux library, but be sure you are setting it up as a provider in the current application.
            – JeffryHouser
            Nov 20 at 13:35















          up vote
          0
          down vote













          Search for this line of the onAuthorize() function:



                user_id: ngRedux.getState().session,


          Change it to this:



                user_id: this.ngRedux.getState().session,


          You are accessing a class variable not a function local variable, so you need to specify the this keyword.



          All this assumes that you have the @angular-redux library property installed as part of your project and that the NgRedux<IAppState> is set up as a provider in your @NgModule.






          share|improve this answer





















          • I got this error now: Cannot read property 'getState' of undefined
            – wwhitewalter
            Nov 19 at 14:00










          • That makes me think that your ngRedux class is not set up as an injectable provider. I don't know anything about the angular-redux library, but be sure you are setting it up as a provider in the current application.
            – JeffryHouser
            Nov 20 at 13:35













          up vote
          0
          down vote










          up vote
          0
          down vote









          Search for this line of the onAuthorize() function:



                user_id: ngRedux.getState().session,


          Change it to this:



                user_id: this.ngRedux.getState().session,


          You are accessing a class variable not a function local variable, so you need to specify the this keyword.



          All this assumes that you have the @angular-redux library property installed as part of your project and that the NgRedux<IAppState> is set up as a provider in your @NgModule.






          share|improve this answer












          Search for this line of the onAuthorize() function:



                user_id: ngRedux.getState().session,


          Change it to this:



                user_id: this.ngRedux.getState().session,


          You are accessing a class variable not a function local variable, so you need to specify the this keyword.



          All this assumes that you have the @angular-redux library property installed as part of your project and that the NgRedux<IAppState> is set up as a provider in your @NgModule.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 13:46









          JeffryHouser

          38.2k42956




          38.2k42956












          • I got this error now: Cannot read property 'getState' of undefined
            – wwhitewalter
            Nov 19 at 14:00










          • That makes me think that your ngRedux class is not set up as an injectable provider. I don't know anything about the angular-redux library, but be sure you are setting it up as a provider in the current application.
            – JeffryHouser
            Nov 20 at 13:35


















          • I got this error now: Cannot read property 'getState' of undefined
            – wwhitewalter
            Nov 19 at 14:00










          • That makes me think that your ngRedux class is not set up as an injectable provider. I don't know anything about the angular-redux library, but be sure you are setting it up as a provider in the current application.
            – JeffryHouser
            Nov 20 at 13:35
















          I got this error now: Cannot read property 'getState' of undefined
          – wwhitewalter
          Nov 19 at 14:00




          I got this error now: Cannot read property 'getState' of undefined
          – wwhitewalter
          Nov 19 at 14:00












          That makes me think that your ngRedux class is not set up as an injectable provider. I don't know anything about the angular-redux library, but be sure you are setting it up as a provider in the current application.
          – JeffryHouser
          Nov 20 at 13:35




          That makes me think that your ngRedux class is not set up as an injectable provider. I don't know anything about the angular-redux library, but be sure you are setting it up as a provider in the current application.
          – JeffryHouser
          Nov 20 at 13:35


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375713%2fts2304-cannot-find-name%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin