angular-ui / bootstrap

PLEASE READ THE PROJECT STATUS BELOW. Native AngularJS (Angular) directives for Bootstrap. Smaller footprint (20kB gzipped), no 3rd party JS dependencies (jQuery, bootstrap JS) required. Please read the README.md file before submitting an issue!
http://angular-ui.github.io/bootstrap/
MIT License
14.3k stars 6.74k forks source link

uib-popover-template not working with webpack #6599

Closed sanjeet1827 closed 6 years ago

sanjeet1827 commented 6 years ago

Hi,

I am using angular 1.6.5 and angular-ui-bootstrap 1.3.3 . I have started using webpack 2.x.x to bundle all my code and templates. But using webpack I found an issue with directive uib-popover-template. As this directive takes path value for template. I want to know how it can be used as template string ?

I tried uib-popover-html too but it does not compile the html string hence does not suits me because my popover template is bound with current controller scope and using uib-popover-html it displays the html correct but scope does get bound (Hence not able to perform events like ng-click).

has anyone faced slimier issue?

Thanks in advance.

dlefloch commented 6 years ago

Hi same issue here, I get the following error messages with same version 1.3.3/webpack 2:

ERROR in ./~/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js Module not found: Error: Can't resolve '/Users/didierlefloch/Development/Github/tq-poc/app/client/uib/template/timepicker/timepicker.html' in '/Users/didierlefloch/Development/Github/tq-poc/node_modules/angular-ui-bootstrap/dist' resolve '/Users/didierlefloch/Development/Github/tq-poc/app/client/uib/template/timepicker/timepicker.html' in '/Users/didierlefloch/Development/Github/tq-poc/node_modules/angular-ui-bootstrap/dist' using description file: /Users/didierlefloch/Development/Github/tq-poc/node_modules/angular-ui-bootstrap/package.json (relative path: ./dist) Field 'browser' doesn't contain a valid alias configuration after using description file: /Users/didierlefloch/Development/Github/tq-poc/node_modules/angular-ui-bootstrap/package.json (relative path: ./dist) using description file: /Users/didierlefloch/Development/Github/tq-poc/package.json (relative path: ./app/client/uib/template/timepicker/timepicker.html)

I tried to define an alias in my webpack config but it did not work:

config.resolve = { alias: { uib: path.join(__dirname, 'node_modules', 'angular-ui-bootstrap') } };

Thank you for your help,

Didier

sanjeet1827 commented 6 years ago

Hi,

Thanks for replying.

I found other way to fix this issue. Put the template in $templateCahe at the time when application is bootstrapped in angular module like below

var popOverTemplate = require("path/to/popovertemplate"); .run(["$templateCache",($templateCache)=>{ $templateCache.put("popOverTemplate",popOverTemplate ) }]);

Then use it via uib-popover-temlate like below.

stereokai commented 6 years ago

@sanjeet1827 you saved my life man!!!