I called data from the server using ngResource . however, I found out that for some reason my controller is being called twice.
Here is my code;
App.js File
// declare a module var blogApp = angular.module('blogApp', ['ngResource']);
File HomeController.js;
blogApp.controller("HomeController", function ($scope, $resource) { var HotNews = $resource('/api/article/hotnews?culture=en-US'); $scope.news = HotNews.query(); alert("hello");
my opinion;
<ul id="news" data-ng-controller="HomeController"> <li data-ng-repeat="headline in news"> {{headline.description}} <a href="#" title="Read More">ยป more</a> </li> </ul>
Updated: the problem is in the fancybox.js file, which is in the main layout;
<html data-ng-app="blogApp">
source files:
<script src="/Content/scripts/lib/angular.min.js"></script> <script src="/Content/scripts/lib/angular-resource.min.js"></script> <script src="/Content/scripts/app/app.js"></script> <script src="/Content/scripts/app/controllers/HomeController.js"></script> @Scripts.Render("~/bundles/jquery") <script src="/content/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
when I comment on fancybox everything works fine, but when I add it back, I get a warning window twice;
source share