问题标签 [angular-templatecache]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
261 浏览

laravel-elixir - mix.ngTemplates 不是函数()

我按照简短的教程在我的应用程序中安装了一个 html 模板缓存包:laravel-elixir-ng-templates我安装并配置了它,但现在当我尝试运行 gulp 时,我收到以下错误:

在此处输入图像描述

这是我的 gulpfile.js:

现在我对 gulp 和 elixir 都是新手,所以我可能在这里做错了什么,尽管我不知道是什么。

0 投票
1 回答
161 浏览

android - 离子模板缓存在设备上不起作用,仅在浏览器中起作用

我在我的 Ionic 应用程序中实现了gulp-angular-templatecache-ionic,这使我的应用程序在我的桌面 chrome 浏览器中运行得更快,但是当我构建和部署(ionic run android)这个应用程序到我的设备(LG Nexus 5x)时它是还是很慢,好像什么都没变,好像内置的android版本没有使用angular模板缓存。我关注了这篇文章:http ://tombuyse.com/improving-the-performance-of-your-ionic-application/

任何想法或建议如何调试?

谢谢!

0 投票
0 回答
252 浏览

angularjs - 我想在 gulp 中禁用 templateCache 功能

我正在为我的一个角度项目使用 gulp。我想知道如何在 gulp 中禁用 templateCache 的东西。我尝试在 build.js 中评论一些代码,但没有奏效。这是 build.js 中的代码。

0 投票
2 回答
217 浏览

javascript - UI Router controller not working when view is pulled in with $templateCache?

I am using gulp-angular-templatecache to convert all of my filename.view.html files into a templates.js file.

I'm then using $stateProvider to create my states and pull in the templates using $templateCache, with an abstract "root" state.

Up to this point everything works fine. The templates load into my page just as they should, but no matter what I do I cannot get the controllers to work.

My modules and associated controllers are relatively simple:

I have tried a few different ways around this but none have appeared to work:

  • Moved template into the .run(...) section of the module and pushed it into $templateCache there instead
  • Different variations of template, templateUrl and templateProvider inside of the state config
  • Removing the controllerAs syntax from the state and using ng-controller instead
  • Using the old-style controller syntax (i.e. not controllerAs syntax)

Does anyone have any suggestions on how I may resolve this issue? I've been tearing my hair our for hours!

0 投票
1 回答
781 浏览

javascript - $templateCache 在 Angular.js 的 angular-config 中不起作用

我在我的 app.config 块中尝试使用 $templateCache 时收到“angular.min.js:6Uncaught Error: [$injector:modulerr]”,如果我从 app.config 中删除 $templateCache 参数,那么我看不到任何错误。如果我错过了什么,请告诉我。提前致谢。

0 投票
1 回答
305 浏览

gulp - gulp-angular-templatecache 找不到它创建的模板文件

我们正在使用 AngularJS 和 ASP.NET Web API 开发一个 Web 应用程序。有一个使用 GoCD 设置的开发机器,它在每次提交到我们的 github 存储库中的 dev 分支后部署应用程序。我们正在使用 gulp 构建前端,但在最后一次提交后,其中一项任务无法完成。

很明显,这个特定的提交与它无关,因为它是一个微不足道的 9 行 css 修复。违背所有逻辑,我们决定恢复,但没有帮助。Gulp 在 Windows 10 和 Linux 上运行良好,但在 Windows Server 2012 上失败。目前尚不清楚原因,因为它在 3 个月内运行良好。

失败的任务:

angularTemplateCache 失败并显示错误消息,它找不到“..src/app/templateCacheHtml.js”,但这是它应该创建然后移动到“/partials/templateCacheHtml.js”的文件。

我们试图找到一些线索来说明导致它的原因,但没有任何东西与该问题有任何远程联系。它在我们的本地机器上完美运行。

0 投票
2 回答
504 浏览

javascript - 覆盖 $templateCache 使其不区分大小写

$templateCache一个人可以在保持对原始提供者的引用的同时覆盖核心提供者吗?我想覆盖$templateCache不区分大小写。

IE 之类的

但不那么 hacky,更多 DI 风格?

0 投票
1 回答
86 浏览

javascript - 在 Angular 1.x 中使用 $templateCache 和 ui-router 和 uglify

将此作为 Qusstion-answer 帖子分享。

当您必须在 ui-router 中使用$templateCache路由templateProvider并且必须使用代码时该怎么办?注入不起作用,角度不能通过引用注入。

例子 :

0 投票
0 回答
80 浏览

angularjs - MVC 中的 AngularJS,预加载静态 HTML 或 MVC 部分视图以使用 @templateCache 使应用程序脱机?

我们有一个 MVC 项目,上面有 AngularJS。问题 - 是否可以将静态 HTML 文件(部分模板)预加载到Angular 的自定义组件或指令的templateUrl属性中。

如果可能的话,我可以使用 Angular 的@templateCache使项目离线工作吗?

我问的原因是在我发现的所有示例中,没有 MVC,只有普通的 html 文件夹结构。

但是对于 MVC,加载视图的所有请求都通过 MVC 控制器的 Action 来加载视图。

因此,由于我没有 .html 文件,因此通过指定templateUrl: 'mypartialview.html'将什么也不做,也没有这样的路径可以告诉 templateUrl 在哪里寻找模板。通过指定templateUrl: '/HomeController/mypartial/'- 这可以做到吗?获得部分视图?

如果是,我可以使用 Angular 的@templateCache缓存它以使项目脱机工作吗?

谢谢。

0 投票
0 回答
615 浏览

javascript - 在大型应用程序的情况下使用 Angular 的 templateCache

我正在使用 100 多个模板优化一个相当大的 angularjs 应用程序。我使用 grunt 进行自动化。我在这里想要实现的是,我需要在生产代码中的所有 url 前面加上一个 cdnUrl,因为我计划在 cdn 上托管静态资产。

我尝试使用这个grunt 插件来做到这一点,并且我成功地替换了代码中的所有引用,除了<ng-include>标签中的 templateUrls 和 UI 路由器状态配置中的那些。

$templateCache因此,我想通过使用插件的服务将我所有的 Angular js 模板预编译到单个 js 文件中来解决该问题。在检查了预编译的 js 文件的大小后,我发现即使将 html 缩小,它也高达 1.13 MB。

与我的整个应用程序相比,我的整个应用程序在第一次加载时只需要1.5 ~ 1.7 mb。所以我觉得包含这个预编译的模板是不清晰的,它会强制在用户的设备上下载大量额外的重量。还有一些视图部分仅限于某些用户,一般来说,我觉得为应用程序的那些部分加载数据是不公平的,许多用户无论如何都不会访问。

那么你们在这种情况下有什么建议呢?在生产中使用 $templateCache 是否仍然更可取?如果没有任何关于使用 grunt 为带有 cdn url 前缀的角度模板的帮助将是有帮助的。