Error: Unexpected request: GET views/partials/* for a nested directive even when using html2js in karma/jasmine unit test

自闭症网瘾萝莉.ら 提交于 2019-12-05 07:54:18

The directive A's template URL is /views/partials/directivea.html. This doesn't cause an HTTP GET to be executed because the template is stored in the cache by the preprocessor:

  ngHtml2JsPreprocessor: {
    stripPrefix: "app",
    moduleName: "template-module"
  }

But there is a GET request executed for views/partials/directiveb.html. Note the difference with the first URL: it doesn't have a leading /. The template cache has an entry for the partial, but its URL in the cache is /views/partials/directiveb.html, not views/partials/directiveb.html.

Make sure you consistently use absolute or relative paths, and depending on your choice, strip the app prefix or the app/ prefix in the preprocessor configuration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!