Skip to content

Instantly share code, notes, and snippets.

@timelf123
Last active February 6, 2017 16:35
Show Gist options
  • Save timelf123/d43777768d2041c070ea13d75d27def1 to your computer and use it in GitHub Desktop.
Save timelf123/d43777768d2041c070ea13d75d27def1 to your computer and use it in GitHub Desktop.
Change Angular Scope via AB testing tool

How to Change the AngularJS Model from VWO

  • In VWO, set up a test
  • add js/css variation
<script>
// get Angular scope from a known DOM element
e = document.getElementById('someElement');
scope = angular.element(e).scope();
// update the model with a wrap in $apply(fn) which will refresh the view for us
scope.$apply(function() {
	scope.property = 'foo';
});
</script>

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