Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Parametro angulara con ruta y recarga de componente

import { Component, OnInit, ElementRef, Renderer } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { productModel } from '../_models/index';
import { categoryListService } from '../_services/index';

@Component({
  selector: 'app-product',
  templateUrl: 'product.component.html',
  styleUrls: ['product.component.css']
})
export class productComponent implements OnInit {
  uidproduct: productModel;
  param: number;
  constructor(
    private elementRef: ElementRef,
    private route: ActivatedRoute,
    private router: Router,
    private categoryListService: categoryListService) { }

  ngOnInit() {
    this.route.params.subscribe(product => {
      console.log('logging sub product obj', product);
    });
    this.uidproduct = JSON.parse(sessionStorage.getItem('product'));
    var s = document.createElement("script");
    s.type = "text/javascript";
    s.src = "http://this/external/script/needs/to/be/loaded/each/time.js";
    this.elementRef.nativeElement.appendChild(s);
  }
  nextproduct(){ 
    let i = this.uidproduct.order;
    this.categoryListService.findNextproduct(this.uidproduct);
    this.param = ++i;
    this.router.navigate([`/product/${this.param}`]);
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: loop through async javascript -2 
Javascript :: dollar sign brackets javascript 
Javascript :: react native delay input 
Javascript :: jsx tag with children react js 
Javascript :: salman javascript id 
Javascript :: react-navigation headerbackbutton not export member of navigation 
Javascript :: array[-1] not working 
Javascript :: normalizedList.flatMap is not a function vue draggable 
Javascript :: enquire js - simple media query library for Javascript 
Javascript :: event module 
Javascript :: split a table by sertain number of entities javascript 
Javascript :: react 5 to 10 rating 
Javascript :: initialize back4app 
Javascript :: AJAX XML - update new live data and prevent returning old chache data 
Javascript :: hide parent component when child component loaded 
Javascript :: js video controls false 
Javascript :: state changes when changing route useContext next 
Javascript :: Spread Syntax for array literals or strings 
Javascript :: como acrescentar item no array js 
Javascript :: catch the last item in a array js 
Javascript :: Raphael JS store arbitrary data 
Javascript :: select triggers mouseleave 
Javascript :: useContext from localhost 
Javascript :: set @Output through modalref angular 
Javascript :: Subscription field must return Async Iterable. Received: undefined. 
Javascript :: discord.js send dm to specific user 
Javascript :: column chart in js 
Javascript :: discord.js v13 afk command 
Javascript :: instant search initial value 
Javascript :: release mouse key javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =