TypeError: $(…).modal is not a function with bootstrap Modal

前端 未结 14 1886

I have a bootstrap 2.32 modal which I am trying to dynamically insert into the HTML of another view. I\'m working with Codeigniter 2.1. Following Dynamically inserting a boo

14条回答
  •  隐瞒了意图╮
    2020-11-29 04:42

    Run

    npm i @types/jquery
    npm install -D @types/bootstrap
    

    in the project to add the jquery types in your Angular Project. After that include

    import * as $ from "jquery";
    import * as bootstrap from "bootstrap";
    

    in your app.module.ts

    Add

    
    

    in your index.html just before the body closing tag.

    And if you are running Angular 2-7 include "jquery" in the types field of tsconfig.app.json file.

    This will remove all error of 'modal' and '$' in your Angular project.

提交回复
热议问题