Reputation: 53
I want to inject one HTML element which has been announced with angular directives. With jquery. but the application is not working.
<!doctype html>
<html>
<head>
<title>test angular</title>
</head>
<body>
<div id ="header" ng-app="loginApp"></div>
<script src="js/jquery.js"></script>
<script src="js/angular.js"></script>
<script>
$("#header").load("header.html");
var app=angular.module("loginApp",[]);
app.controller("loginCtrl",function(){
$scope.data="mydata";
});
</script>
</body>
</html>
and the header.html is :
<div ng-controller="loginCtrl">
{{data}}
</div>
but there is no result also no error messages:
Upvotes: 1
Views: 157
Reputation: 5605
You can use the ngInclude
directive for that:
<div ng-controller="loginCtrl">
<div ng-include="'header.html'"></div>
</div>
Upvotes: 1