如果有人有这样的问题,请帮忙.
我使用Angular+ Webpack并试图要求我的JS使用HTML文件html-loader.
起初我需要html文件到我的directive
var templateUrl = require('./test.html');
Run Code Online (Sandbox Code Playgroud)
然后我做webpack命令和webpack说一切都很好,捆绑所有文件没有任何问题.
然后我有一个错误(它在我的控制台中):
[$compile:tpload] Failed to load template: <div class="test">
<p>This is my TEST</p>
</div> (HTTP status: 404 Not Found)
Run Code Online (Sandbox Code Playgroud)
据我所知,它看到了我的HTML,但在此之前,它表示无法获取它(模板),为什么会这样?
请求在网络中
GET http://127.0.0.1:7773/portal/%3Cdiv%20class=%22test%22.....
Run Code Online (Sandbox Code Playgroud)
例如,成功需要:
Request URL:http://127.0.0.1:7773/portal/dev/bundle.js
Run Code Online (Sandbox Code Playgroud)
据我所知,webpack在另一个地方看它.怎么解决?
有关信息我的完整路径:
/home/darthjs/Documents/****/src/public/portal/app/components/navtop/test.html
Run Code Online (Sandbox Code Playgroud) 观看回复时遇到问题.
我有一个SettingsCtrl作为设置,这是我的观点:
<input type="text" class="form-control" ng-model="settings.test.one" />
<input type="text" class="form-control" ng-model="settings.test.second" />Run Code Online (Sandbox Code Playgroud)
这是我的控制器:
app.controller('SettingsCtrl', function ($scope, settingsFactory, Test) {
var vm = this;
settingsFactory.test().then(function(response){
vm.test = response;
})
///// OR
vm.test = Test; // this is from ui-router resolve
$scope.$watch(angular.bind('vm', function () {
return vm.test;
}), function (newV, oldV) {
console.log(newV, oldV);
});
$scope.$watch(function watch(scope){
return vm.test;
}), function handle(newV, oldV) {
console.log(newV, oldV);
});
$scope.$watch('vm', function (newVal, oldVal) {
console.log('newVal, oldVal', newVal, oldVal);
});
});Run Code Online (Sandbox Code Playgroud)
我一直在寻找并找到了不同的解决方案,但没有解决方案.
****它只是第一次观看,当控制器加载并且我看到我的控制台日志时,但是当我尝试进行更改时,观察者什么都不做.
我做错了什么?