Skip to content

solve interpolation issue#20

Open
merlosy wants to merge 2 commits intomike-spainhower:masterfrom
merlosy:patch-1
Open

solve interpolation issue#20
merlosy wants to merge 2 commits intomike-spainhower:masterfrom
merlosy:patch-1

Conversation

@merlosy
Copy link

@merlosy merlosy commented Jul 17, 2015

You can now insert config in your directive with something like:

<div ng-if="piwikConfig.active">
      <ngp-piwik ngp-set-js-url="{{piwikConfig.urlJs}}" 
                  ngp-set-tracker-url="{{piwikConfig.urlPhp}}" 
                  ngp-set-site-id="{{piwikConfig.siteId}}"> 
      </ngp-piwik>
    </div>

using a definition of your constant like:

 app.constant('piwikConfig', {
        active: true,
        urlJs: "http://mypiwiksite.com/piwik.js",
        urlPhp: "http://mypiwiksite.com/piwik.php",
        siteId : 3
    });

merlosy added 2 commits July 17, 2015 15:46
You can now insert config in your directive with something like:
```
<div ng-if="piwikConfig.active">
      <ngp-piwik ngp-set-js-url="{{piwikConfig.urlJs}}" 
                  ngp-set-tracker-url="{{piwikConfig.urlPhp}}" 
                  ngp-set-site-id="{{piwikConfig.siteId}}"> 
      </ngp-piwik>
    </div>
```
using:
 app.constant('piwikConfig', {
    	active: true,
        urlJs: "http://mypiwiksite.com/piwik.js",
        urlPhp: "http://mypiwiksite.com/piwik.php",
        siteId : 3
    });
@SpainTrain
Copy link
Collaborator

This looks great, thanks for the PR. I'd love to merge after a couple minor changes:

  • Can we add a test for this functionality?
  • Can we add directions/example to the README.md?
  • Could you squash this down into one commit?

Thanks again!

@merlosy
Copy link
Author

merlosy commented Jul 17, 2015

Well, I'll see when I'll have more time..
Does it really need more tests for it? I'm not sure it's a new feature.

I tried to commit the files from git CLI but i'm not a contributor, so it's a bit hard to have it all in one single commit. For this PR, I copied/pasted in the online editor.

@merlosy
Copy link
Author

merlosy commented Jul 17, 2015

Or i can work on a fork too...

@SpainTrain
Copy link
Collaborator

Testing

Yes, believe it is appropriate to have tests for this functionality.

It would not require a new test per se, but the beforeEach block that sets up the tests needs to use interpolation, e.g.,

inject ($rootScope, $compile, $window) ->
      elm = angular.element '''<div>
        <ngp-piwik
          ngp-set-js-url="{{piwikConfig.urlJs}}"
          ngp-set-tracker-url="{{piwikConfig.urlPhp}}"
          ngp-set-site-id="{{piwikConfig.siteId}}"
          ngp-set-domains="www.test.com,demo.test.com">
        </ngp-piwik>
      </div>'''
      scope = $rootScope
      $window['_paq'] = undefined
      win = $window
      $compile(elm)(scope)
      scope.$digest()
      return
    return

and stick the config on scope or as a constant in your example.

Squashing

Sounds like you need to add your fork as a remote on the CLI:

git remote add merlosy git@github.com:merlosy/angular-piwik.git

If you use the hub app, you can just run git fork to do the same thing.

Now that you have your fork's branch locally you can squash the commits. There are multiple approaches to squashing, but rebasing is one option, as described here http://eli.thegreenplace.net/2014/02/19/squashing-github-pull-requests-into-a-single-commit

Also, I am happy to squash the commits and merge them to master once this is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments