Description

The search conditional directive

Usage

as element:
<search:conditional
       [test="{string}"]
       [response="{object}"]>
</search:conditional>

Directive info

  • This directive creates new scope.

Parameters

ParamTypeDetails
test (optional)stringThe expression to test conditional logic for. Only render the contents tag if this evaluates to true.
response (optional)objectA Response object to check, the tag will render the body if the Response is not null.

Example

Source

<h3 id="example_test-attribute">Test Attribute</h3>
<search:conditional test="test1 > 100">
    <p>False don't display</p>
</search:conditional>

<search:conditional test="test1 >= 100">
    <p>True! test1 is greater than or equal to 100</p>
</search:conditional>

<search:conditional test="test2">
    <p>True! test2 is true</p>
</search:conditional>

<search:conditional test="test3 == 'Foo'">
    <p>False don't display</p>
</search:conditional>

<search:conditional test="test3 == 'foo'">
    <p>True test3 does equal foo</p>
</search:conditional>

<hr/>

<h3 id="example_response-attribute">Response Attribute</h3>

<search:conditional response="response">
    <p>True! Response does exist.</p>
</search:conditional>

<search:conditional response="response2">
    <p>False! Response2 does not exist.</p>
</search:conditional>
angular.module('lightning')
.controller('ExampleController', ['$scope','ResponseService', function($scope,ResponseService) {
            $scope.test1 = 100;
            $scope.test2 = true;
            $scope.test3 = 'foo'

            ResponseService.setResponse('response', {foo:'bar'});
        }]);

Result

Result