Direcitve TEst

leanwx.com

HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/black-tie/jquery-ui.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
    <div ng-controller='TestCtrl'>
        <ng-switch on="switchMe">
            <div ng-switch-default>Loading...</div>
            <div ng-switch-when="true">
                <form name="nixTest">
                    <input placeholder='In switch' ng-model='dummy'></input>
                    <button ng-click="test()">Submit</button>
                </form>
            </div>
        </ng-switch>
    </div>
<hr />
<div ng-controller='TestCtrl'>
    <form name="nixTest">
        <input placeholder='No switch' ng-model='dummy'></input>
        <button ng-click="test()">Submit</button>
    </form>
</div>

JavaScript

var leanwxApp = angular.module('LeanwxApp', [], function () {});

var controllers = {};
var directives = {};
    
    controllers.TestCtrl = function ($scope) {
        $scope.switchMe = true;
        $scope.test = function () {
    
            if ($scope.nixTest) {
                alert('nixTest exists')
            } else {
                alert('nixTest DNE')
            }
        }
    }

leanwxApp.controller(controllers);
leanwxApp.directive(directives);