I have a REST service that fetch data from back end and show the notifications to user when click notification button.Initially notification div is hide and when button click it will show with REST data.As a draw back i have figured out REST call takes sometime to load and it will cause my main page loading slow. Because even without click notification button data will be loaded.As a solution i integrated ajax to load the notification div content.In ajax call i load html page into notification div using ajax.
ajax code snippet when notification button click
<script>
$(function() {
$("label").click(function() {
$.ajax({
url: "notify/notification.html",
success: function(result) {
$(".ajax-notifications").html(result);
}
});
});
});
</script>
In notification.html i call the REST service.But the problem is that page successfully load but REST call doesn't execute.Even doesn't show any errors in console.I am newbie to Angularjs appreciate any help or any ideas to do this in better way.
Main Page
<div class="ajax-dropdown" style="left: 128px;">
<div class="btn-group btn-group-justified" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="activity" id="javascript:void(0)">
Notifications (0) </label>
</div>
<!-- notification & tasks content -->
<div class="ajax-notifications custom-scroll">
<div class="alert alert-transparent">
No Notification or Tasks available at this time.
</div>
</div>
</span>
</div>
notification html
<!DOCTYPE html>
<html ng-app="postExample">
<head>
<script src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular-resource.js"></script>
<script type="text/javascript" src="js/usersController.js"></script>
<script type="text/javascript" src="js/userRepoService.js"></script>
</head>
<body ng-controller="UsersController">
<h1>Notifications</h1>
<select id="UserSelector" style="width: 100%;">
<option ng-repeat="user in users" value="{{user.displayName}}">{{user.displayName}}</option>
</select>
</body>
</html>
$("notify").click(). Are you binding click event to appropriate component ?