示例#1
0
 /**
  * Compiles AngularJS ng-class-odd attributes by evaluating expression inside it
  * and setting element's class attribute if element has odd index.
  *
  * @param \DOMElement $element DOM element to compile.
  * @param Scope $scope Scope object containing data for expression.
  * @return \DOMElement Compiled DOM element.
  */
 public function compile(\DOMElement $element, Scope $scope)
 {
     if ($scope->getData('$odd') == true) {
         $ngClass = new NgClass($this->phCompile);
         $ngClass->compile($element, $scope);
     }
 }
示例#2
0
 /**
  * @covers PhCompile\Template\Directive\NgClass::compile
  * @dataProvider compileExceptionProvider
  * @expectedException PhCompile\Template\Expression\InvalidExpressionException
  */
 public function testCompileException($scopeData, $classString)
 {
     $this->scope->setData($scopeData);
     $document = Utils::loadHTML('<span ng-class="' . $classString . '"></span>');
     $element = $document->getElementsByTagName('span')->item(0);
     $this->ngClass->compile($element, $this->scope);
 }