0

Problem: I want to make a directive that works like this:

svg-icon('company-logo')

I'd also eventually like this to be (jade/html):

svg-icon('company-logo', { height: '3em', width: '3em'})

<svg-icon company-logo height="3em" width="3em"/>

And I want it to return an svg template with the correct logo. I'd also like certain parameters to be configurable like fill color, height, and width. I've done a first try and this is the first snippet:

https://gist.github.com/anonymous/9be8f111591b15fde9be

Right now what's happening other than not working is provider namespace errors and various injector warnings for iconConfig and iconConfigProvider. I'm wondering what I'm doing wrong and how I should approach this problem.

I'm looking at a few blog posts to help:

Creating Configurable Angular Directives with Providers

AngularJS: Factory vs Service vs Provider

and finally, Angular's own docs:

Provider Recipes

I still have no idea how to do this.

Gina
  • 570
  • 2
  • 5
  • 20
  • Did you ever have directive working without all the provider config? Pretty hard for anyone to help without more specific problems identified. Maybe just need to work on directive itself and pass in a config object from a controller to get started. Then worry about moving parts of it to service or provider after – charlietfl Aug 14 '15 at 01:45
  • Yes, the directive did work without provider config. I was using a controller before, but wanted to do it better. I might just have to ditch this approach. – Gina Aug 14 '15 at 03:52

0 Answers0