问题
In my previous Play app, I used to use Webjars & RequireJS to manage dependencies. I could use require(['angular', 'webjars!ui-bootstrap-tpls.js'], function(angular) {...}) without problem.
Recently I updated webjars and several webjars related deps (webjars-ui-bootstrap, etc.) to the latest version on www.webjars.org, and I found webjars! loader plugin not working properly. I checked out the webjars-seed-play app and modified some code like:
require(['angular', './controllers', './directives', './filters', './services', 'angular-route', 'webjars!ui-bootstrap-tpls.js'],
function (angular, controllers) {
// Declare app level module which depends on filters, and services
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'ngRoute', 'ui.bootstrap']).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: controllers.MyCtrl1});
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: controllers.MyCtrl2});
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
angular.bootstrap(document, ['myApp']);
});
It just complains that ui.bootstrap is not available, which should be loaded by webjars!ui-bootstrap-tpls.js in my opinion. What am I doing wrong here? Please help me. Thanks.
My deps in build.sbt:
libraryDependencies ++= Seq(
"org.webjars" %% "webjars-play" % "2.2.1-2",
"org.webjars" % "angularjs" % "1.2.13",
"org.webjars" % "bootstrap" % "3.1.1",
"org.webjars" % "requirejs" % "2.1.11-1",
"org.webjars" % "angular-ui-bootstrap" % "0.10.0"
)
回答1:
Sorry about the hassle. Now that RequireJS is officially supported in WebJars we had to make some changes: http://www.jamesward.com/2014/02/19/official-support-for-requirejs-in-webjars
In short, the webjars!
plugin loader has been replaced with just normal RequireJS modules and path configs. Some of the WebJars haven't been updated yet. So if you run into problems please file an issue against the WebJar.
来源:https://stackoverflow.com/questions/22242605/how-to-use-webjars-loader-plugin