1

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:

enter image description here

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
vincent
  • 43
  • 5

1 Answers1

1

You can use the ngInclude directive for that:

<div  ng-controller="loginCtrl">
    <div ng-include="'header.html'"></div>
</div>
Martijn Welker
  • 5,575
  • 1
  • 16
  • 26