如何从Phoenix框架应用程序加载AngularJS模板?我正在使用ui-router使用templateUrl加载模板。这是角度1.5。
myAppModule.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', function ($stateProvider, $urlRouterProvider, $httpProvider) {
$stateProvider
.state('event', {
url: '/event',
templateUrl: '/templates/event/event.html'
// template: '<h1>Stuff</h1>'
})
$urlRouterProvider.otherwise('/event');
}]);
加载内联模板的工作原理很明显,因此很明显,这是我正在努力加载的模板的机制。我需要更改早午餐配置中的任何设置吗?
谢谢
Eamon
嗯,这不是太简单。我遇到了同样的问题,因此这是我的解决方案。 Phoenix Framework有一个目录,您可以在其中放置HTML文件,该目录的名称为web/static/assets
,您可以在其中设置文件,但是如果您需要创建一个类似于web/static/assets/templates
的目录,则需要在[ C0],例如:
endpoint.ex
现在您可以重新编译并运行Elixir代码,并像这样加载文件:
plug Plug.Static,
at: "/", from: :app, gzip: false,
only: ~w(css fonts images templates js favicon.ico robots.txt)
我希望对您也有用。