Я пытаюсь получить пользовательскую директиву, работающую в угловом, частично следуя official document.demo пользовательской директивы
В Chrome я вижу только пустую страницу.
F12 показывает эту ошибку:
XMLHttpRequest cannot load file:///home/jeff/workspace/angularjs-intro/playground/my-customer.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
Вот что я получил до сих пор:
(function() {
var app = angular.module('docsRestrictDirective', []);
app.controller('Controller', function() {
});
app.directive('myCustomer', function() {
return {
restrict: 'E',
templateUrl: 'my-customer.html'
};
});
})();
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example14-production</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="docsRestrictDirective">
<div ng-controller="Controller">
<my-customer></my-customer>
</div>
</body>
</html>
И мой-customer.html
Name: {{customer.name}} Address: {{customer.address}}
Любая помощь приветствуется.
Вам нужен DIV, окружающий мой-customer.HTML. также я не вижу, чтобы данные передавались в директиву. – iamrelos
Запустите свой код на сервере. Он бросает ошибку запроса кросс-оригинала. –
Я ответил. Помогает ли вам понять проблему и рекомендуемое решение? –