Loading and Using JavaScript in Angular

Поділитися
Вставка
  • Опубліковано 10 гру 2024

КОМЕНТАРІ • 36

  • @ItaloSaager
    @ItaloSaager 2 роки тому +5

    Thank you mate! worked here!!! I was strougling cause I've never worked with Angular before, I accepted a job that requires this framework and I didn't knew why my script wasn't working. Thank you so much!

  • @mrdiamod
    @mrdiamod 4 роки тому +8

    Hello, bro! You best, you helped me solve a problem! You video helped me understand how to include my file.js when I go from one page to two, that works my file.js!
    Thank you, bro!

  • @iroshanaravishan1388
    @iroshanaravishan1388 2 роки тому +3

    The point is WE NEES TO RESTART TRH SERVER. I tried many, but didn't work any for me.. If the code is not working, please restart the server... Great Vdo😀🙌

  • @nunogoncalves966
    @nunogoncalves966 2 роки тому +3

    The declare function method doesn't seem to work in Angular 13. Do you happen to have a work-around for it? Thanks.

  • @kenCapt8
    @kenCapt8 Рік тому

    Hello I have a question, in timestamp 2:12 what if you have more than one local js file how are you going to include them or even the external js file that is not in your local project

  • @riadamghar6380
    @riadamghar6380 4 місяці тому

    i have a question if you can respond pls , does it work on angular 18 ?

  • @codewithbenji
    @codewithbenji 2 роки тому +1

    this was helpful thanks

  • @ayushaher5022
    @ayushaher5022 3 роки тому

    love you bro... helped a lot

  • @juanreneguzmann.404
    @juanreneguzmann.404 2 роки тому +1

    Love you mannnnn,

  • @amirkian1181
    @amirkian1181 2 роки тому +1

    If the external js file is a library what we should do?

    • @Codeible
      @Codeible  2 роки тому

      Should only need to include the path to the folder.

  • @seifmoustafa3005
    @seifmoustafa3005 3 роки тому +2

    Hello sir I did exactly as you did in the video. However, I can't access elements using document.querySelector or document.querySelectorAll. Only alert and console.log work but the JS file can't access the html elements inside my component. Please provide help

    • @Codeible
      @Codeible  3 роки тому +1

      Hello, if your scripts uses the document object, you will need to do it in the component.

    • @seifmoustafa3005
      @seifmoustafa3005 3 роки тому +1

      @@Codeible would you please tell me how?

    • @Codeible
      @Codeible  3 роки тому +1

      @@seifmoustafa3005 Is it a local file?

    • @seifmoustafa3005
      @seifmoustafa3005 3 роки тому

      @@Codeible yes

    • @seifmoustafa3005
      @seifmoustafa3005 3 роки тому

      @@Codeible sorry I meant to say no

  • @marcelinoatallah1186
    @marcelinoatallah1186 2 роки тому

    Hello sir, if i need to include my js file but only after 'ng serve' and not on reload page

    • @Codeible
      @Codeible  2 роки тому

      Hello, what do you mean?

  • @Billiam112
    @Billiam112 3 роки тому

    Let's say you have a deployed script you'd want to fetch and execute, e.g. a custom script for enhancing application functionality I.e. extensibility, how would you do that?

    • @louisyan135
      @louisyan135 3 роки тому

      Do you mean calling a REST API?

    • @Billiam112
      @Billiam112 3 роки тому

      @@louisyan135 Yeah, so in my use case, customers can create scripts themself to extend/customize the application, e.g disabling a form field they wish never to be enabled (the system is an ERP system), which they can "install" I.e. upload to a server which then the client will call via rest. We have this in place for the old jquery client, but we're now rewriting with angular. Not seeing how one can go about this in a secure way. 🤔

    • @Codeible
      @Codeible  3 роки тому +4

      Hello,
      You need to use the HTTPClient module from Angular.
      I can make a video on that soon.
      What you need is to
      1) Inject HTTPClient to the component
      constructor(private client: HttpClient)
      2) Then call get, post, delete, or put
      For more in depth, you can use this documentation for now:
      angular.io/guide/http

    • @Billiam112
      @Billiam112 3 роки тому

      @@Codeible Thanks, but that's not my main concern. I've been working with angular for many years so I have a good understanding about most of the framework. Definitely http client is used for getting the data/script from the server, my main concerns is security when it comes to loading in some external script in the application. I think I would want to provide users with an scripting api they can use, I.e predefined functions they can call from the script which I can have at least some control of. Oh well, a problem for another workday... 😊

  • @renzo1131
    @renzo1131 Рік тому

    Thanks bro

  • @capybaratech377
    @capybaratech377 3 роки тому

    Thank you for the quick tip. But If I declare the function inside the Constructor() the page crashes. After I left the constructor empty it worked. I don't know why. God bless

    • @Codeible
      @Codeible  3 роки тому +1

      Hello, what do you mean declare the function insided the constructor?
      Do you mean declare var ...? You need to do that outside the component.

    • @capybaratech377
      @capybaratech377 3 роки тому

      @@Codeible Ooooooh. my bad. I'm very noob at Angular. It's very confusing. Thank you for the help. Now it's working. God bless

  • @trungthong7212
    @trungthong7212 3 роки тому

    how to run popup in file js when file js is not declare in file ts?

    • @Codeible
      @Codeible  3 роки тому

      Is file.js a file you have?

  • @IndieGuvenc
    @IndieGuvenc Рік тому

    thanks

  • @richardramos7267
    @richardramos7267 2 роки тому

    thanks, it still confuse me why angular is like this, I just need to simply add a script to my file.

  • @skaffen
    @skaffen Рік тому

    Not working in 2023

  • @bilalekmen4225
    @bilalekmen4225 Рік тому +1

    const amazingMan = 'Codeible';
    console.log('thanks for this nice video ' + amazingMan)