Thank you guys!

On Wednesday, August 20, 2014 9:11:57 AM UTC+2, [email protected] wrote:
>
> When I run my angularjs application, I get the following error message:
>
>> Error: [$rootScope:infdig] 
>> http://errors.angularjs.org/1.2.22/$rootScope/infdig?p0=10&p1=%5B%5B%22safeHtml()%3B%20newVal%3A%20%7B%7D%3B%20oldVal%3A%20%7B%7D%22%5D%2C%5B%22safeHtml()%3B%20newVal%3A%20%7B%7D%3B%20oldVal%3A%20%7B%7D%22%5D%2C%5B%22safeHtml()%3B%20newVal%3A%20%7B%7D%3B%20oldVal%3A%20%7B%7D%22%5D%2C%5B%22safeHtml()%3B%20newVal%3A%20%7B%7D%3B%20oldVal%3A%20%7B%7D%22%5D%2C%5B%22safeHtml()%3B%20newVal%3A%20%7B%7D%3B%20oldVal%3A%20%7B%7D%22%5D%5D
>>
>>
>
> Here is my controller:
>
> var gameApp = angular.module("gameApp", ['ngRoute','ngSanitize']);
>>
>> gameApp.service('link', function() {
>>     this.user = false;});
>> gameApp.filter('unsafe', function($sce) {
>>     return function(val) {
>>         return $sce.trustAsHtml(val);
>>     };});
>>
>> gameApp.directive('mapActivity', function() {
>>     return {
>>         restrict: 'A',
>>         link: function(scope, element, attr) {
>>            scope.$watch(attr.ngBindHtml, function(value) {
>>               angular.element('.click#1').addClass('dotted').html($('<img 
>> src="images/dot.png">'));   
>>                 angular.element('.click').click(function() {
>>                     if(angular.element(this).hasClass('monster'))
>>                     {
>>                     }
>>                     else
>>                     {
>>                         angular.element('.click.dotted').empty();
>>                         
>> angular.element('.click.dotted').removeClass('dotted');
>>
>>                         if(!angular.element(this).hasClass('dotted'))
>>                         {
>>                             angular.element(this).addClass('dotted');
>>                             angular.element(this).html($('<img 
>> src="images/dot.png">'));
>>                         }
>>                     }
>>
>>                 });                     
>>            });
>>         }
>>     };});function makeTableFrom(str) {
>>     var k = 1;
>>     result = "";
>>
>>     for(var i = 1; i <= 8; i++) {
>>         result += '<tr>';
>>
>>         for(var j = 1; j <= 20; j++) {
>>             if(str[k] == '#') {
>>                 result += '<td id=' + k + '">#</td>';
>>             }
>>             else if(str[k] == '&') {
>>                 result += '<td class="click" val="water" id="' + k + 
>> '">&</td>';
>>             }
>>             else {
>>                 result += '<td class="click" id="' + k + '"></td>';
>>             }
>>
>>             k++;
>>         }
>>         result += '</tr>';
>>     }
>>     return result;}
>>
>>
>> gameApp.config(function($routeProvider) {
>>     $routeProvider
>>
>>     .when('/', {
>>             templateUrl : 'partials/firstpage.html',
>>             controller  : 'firstPageCtrl'
>>     })
>>
>>     .when('/game', {
>>             templateUrl : 'partials/game.html',
>>             controller  : 'gameCtrl'
>>     });
>> });
>>
>> gameApp.controller("firstPageCtrl", function($scope,$http,link,$location) {
>>     $scope.doLogin = function() {
>>         $http.post("lib/action.php", {username: $scope.username, password: 
>> $scope.password}).success(function(data) {
>>             if(data) {
>>                 link.user = data;
>>                 console.log(link.user);
>>                 $location.path("/game");
>>             }
>>         }).error(function(data) {
>>             console.log(data);
>>         });
>>     };});
>>
>>
>> gameApp.controller("gameCtrl", 
>> function($scope,$http,link,$location,$sce,$rootScope) {
>>
>>     $scope.getMonsters = "1";
>>
>>     $http.post("lib/action.php", {monsters: 
>> $scope.getMonsters}).success(function(data) {
>>         $scope.result = makeTableFrom(data);
>>     });
>>
>>     $scope.safeHtml = function() {
>>         return $sce.trustAsHtml($scope.result);
>>     };
>>     if(link.user) {
>>         /*$scope.message = "fisk";
>>         console.log(link.user);*/
>>     } else {
>>         /*$scope.message = "Ledsen fisk";
>>         console.log("Är inte satt");*/
>>     }
>> });
>>
>>
> Here is my HTML
>
>> <div ng-controller="gameCtrl">
>>     <table ng-bind-html="safeHtml()" map-Activity>
>>     </table>
>> </div>
>>
>  
> Anyone who can help me? I can't find the cause to this error. This error 
> apperad when I added scope.$watch in my directive.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to