Итак, у меня есть приложение, которое я построил, используя yo angular , и все работает некоторое время.
Я переопределил некоторые из шаблонов начальной загрузки (в частности, datepicker ), и я обновил мою задачу grunt, чтобы включить эти файлы при создании templateCache:
ngtemplates: {
dist: {
options: {
module: 'sapphire',
htmlmin: '<%= htmlmin.dist.options %>',
usemin: 'scripts/scripts.js'
},
cwd: '<%= yeoman.app %>',
src: [
'app/**/*.html',
'uib/**/*.html'
],
dest: '.tmp/templateCache.js'
}
},
Проблема при локальном тестировании. Он не использует новый шаблон, что раздражает.
Я использовал инжектор для добавления файлов моего проекта в мой index.html , поэтому я создал это:
html: {
options: {
transform: function (filePath) {
return '<script type="text/ng-template" src="\'' + filePath.replace('/src/', '') + '\'"></script>';
}
},
files: {
'<%= yeoman.app %>/index.html': [
'<%= yeoman.app %>/uib/**/*.html'
]
}
},
Который добавляет мои шаблоны в конец index.html , например:
<!-- injector:html -->
<script type="text/ng-template" src="'uib/template/datepicker/datepicker.html'"></script>
<script type="text/ng-template" src="'uib/template/datepicker/day.html'"></script>
<script type="text/ng-template" src="'uib/template/datepicker/month.html'"></script>
<script type="text/ng-template" src="'uib/template/datepicker/year.html'"></script>
<script type="text/ng-template" src="'uib/template/timepicker/timepicker.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-account-match.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-complaint.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-customer-services.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-match.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-order-match.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-product-match.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-stock-match.html'"></script>
<script type="text/ng-template" src="'uib/template/typeahead/typeahead-user-match.html'"></script>
<!-- endinjector -->
Эти шаблоны помещаются в файлы JavaScript .
Я попробовал их выше, и все же это не работает. Кто-нибудь знает почему?