0

I'm super new to Angular and JS in general. Basically I have an array thats stored in a var inside a factory and I want that entire array (this.insights) to get imported(?) into my directive.

I believe I need to do something like scope.insights = [];

var Piece = function (parameters) {
  this.thing = null;
  this.that = null;
  this.insights = [
    {
      id: 1,
    }
    {
      id: 2,
    }
  ];
}

1 Answer 1

1

Inject this factory in directive same way you inject other services.

app.directive('helloWorld', function(Piece) {
  return {
   restrict: 'AE',
   replace: 'true',
   template: '<h3>Hello World!!</h3>',
   controller: function(){
     var kek = Piece.insights;
   }
  };
});
Sign up to request clarification or add additional context in comments.

1 Comment

sorry for the late reply, this was exactly what i needed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.