Привет, парень, я относительно новичок в Typescript и Angular, и я пытаюсь выяснить в этом случае: я получил ошибку ниже ошибки при сборке ng, но в ng обслуживать все идет хорошо ... Что за странная проблема заключается в следующем. Также я хочу сделать некоторые заявления, но с частным не работает. Нужно разобраться еще в некоторых хитростях наверное ...
TS2304: не удается найти имя '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);
})
}
}