1

私がする時

/sites/all/themes/theme/js/controller.js

$scope.template = 'partials/tpl.html'

/sites/all/themes/theme/js/index.html

<div ng-include='template'></div>

/sites/all/themes/theme/js/partials/tpl.html

<b>Ho boy!</b>

基本的に、Angular に関連するものはすべて js フォルダーに移動しました。

localhost/partials/tpl.html必要なときに戻ってきますlocalhost/sites/all/themes/js/partials/tpl.html。絶対パスを使用せずにそれを解決するにはどうすればよいですか?

4

2 に答える 2

0

Add a <base href="/sites/all/themes/theme/js/"> at the top of your <head> element inside index.html.

<html>
  <head>
    <base href="/sites/all/themes/theme/js/">
    ...

Reference

Relative links

Be sure to check all relative links, images, scripts etc. You must either specify the url base in the head of your main html file (<base href="/my-base">) or you must use absolute urls (starting with /) everywhere because relative urls will be resolved to absolute urls using the initial absolute url of the document, which is often different from the root of the application.

Running Angular apps with the History API enabled from document root is strongly encouraged as it takes care of all relative link issues.

于 2013-08-23T06:17:42.650 に答える