MathTag is a easy-to-use library that delivers the mathbox as a angular directive.
Just include the MathTag.js file in your html.
Note The file includes
mathbox.js,mathjs,nerdamerand the library itself
<script src="path/to/MathTag.js"></script>###Using Bower
$ bower install mathtagand in your html file:
<script src="bower_components/mathtag/MathTag.js"></script>Add the mathbox module to your app:
var myApp = angular.module('myApp', ['mathTag']);The mathbox element creates a new instance of mathbox.
<math-box>
<curve color="ff00">x^2</curve>
<curve ng-model="f" ng-color="c" domain="[-10, 10]"></curve>
<vector>[[1, 2], [2, 4]]</vector>
</math-box>Important Use e.g. color="#ff0000" for static value and ng-color for data bound properties. Like:
...
<curve ng-color="myColor">x^2</curve>
...
<script>
MainCtrl($scope){
$scope.myColor = 'ff0000';
$scope.changeColor = function(){
$scope.myColor = '00ff00';
//the color of the graph will automatically change
}
}
</script>Like all mathbox primitives curve has certain properties, their names directly match the attributes in math tag.