循环依赖angularjs

时间:2016-07-12 13:22:21

标签: angularjs circular-dependency

任何人都可以告诉我以下代码中的循环依赖是什么?

import java.awt.*;
import java.awt.image.BufferedImage;

import java.io.*;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class Sateen {

    BufferedImage image;
    int width;
    int height;
    int red, green, blue;

    public Sateen() {
        try {

            File input = new File("n.png");
            image = ImageIO.read(input);
            width = image.getWidth();
            height = image.getHeight();
            // n is png file with only white pixels
            for (int i = 0; i < height; i++) {
                for (int j = 0; j < width; j++) { // may not need j++ as you are doing j+5?
                    Color p = new Color(image.getRGB(j, i));
                    int jPlus5 = j + 5;
                    if (jPlus5 < width) {
                        Color g = new Color(image.getRGB(jPlus5, i));
                        // getting (j,i) coordinate pixel value and then
                        // comparing
                        // it to next 5th pixel

                        if (p.getRed() == 255 && p.getBlue() == 255 && p.getGreen() == 255 && g.getRed() == 255 &&
                                g.getBlue() == 255 && g.getGreen() == 255)
                        {
                            red = 0;
                            blue = 0;
                            green = 0;
                        }
                        // if both pixel value is white then setting 5th pixel
                        // value
                        // to black
                        Color newColor = new Color(red, green, blue);
                        image.setRGB(jPlus5, i, newColor.getRGB());                            
                    } 
                    j = jPlus5;
                }
            }

            File ouptut = new File("Sateen.png");
            ImageIO.write(image, "png", ouptut);
            // creating sateen png file
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static public void main(String args[]) throws Exception
    {
        Sateen obj = new Sateen();
    }
}

我被困在这一点请帮我解决这个问题。 这是我在浏览器上遇到的错误 Please click here to see error 谢谢.. !!

1 个答案:

答案 0 :(得分:4)

$ http拦截器无法将$ http声明为依赖项!

注入$ injector:

homeApp.factory('AdminDashboardService', ['$injector', '$q', function($injector, $q){


    return {


        'response': function(response) {
              // do something on success
              console.log("Yes Command comes here");
              return response;
            },

        getAllHolidays: function(monthYearArrayForHolidayList) {
            console.log("For full list of holidays list length: "+monthYearArrayForHolidayList.length);
            var isMonthly="no";
            return $injector.get("$http").get('/tasktrac/holiday/getHoliday/isMonthly/'+isMonthly+'/'+monthYearArrayForHolidayList)
                    .then(
                            function(response){
                                return response.data;
                            }, 
                            function(errResponse){
                                //console.error('Error while fetching holiday');
                                return $q.reject(errResponse);
                            }
                    );
    },
}]);