
Tworzenie własnej usługi wAngular | 167
})
export class CreateStockComponent {
public stock: Stock;
public confirmed = false;
public exchanges = ['NYSE', 'NASDAQ', 'OTHER'];
constructor(private stockService: StockService,
public messageService: MessageService) {
1
this.stock = new Stock('', '', 0, 0, 'NASDAQ');
}
setStockPrice(price) {
this.stock.price = price;
this.stock.previousPrice = price;
}
createStock(stockForm) {
if (stockForm.valid) {
let created = this.stockService.createStock(this.stock);
if (created) {
2
this.messageService.message =
'Successfully created stock with stock code: ' +
this.stock.code;
this.stock = ...