><form name="form" novalidate role="form" data-sm:dirty-check data-server:error > ng-show="$parent.showForm && !selections.justDeleted" class="ng-cloak">>
> app.directive('smDirtyCheck', ['$modal', '$rootScope', '$location', '$state', 'resourceFactory', > function ($modal, $rootScope, $location, $state, resourceFactory) { > return { > restrict: 'A', > require: ['^form'], > scope: { > onOk: '&', > onCancel: '&' > }, > link: function (scope, element, attrs, controllers) { > > var form = controllers[0]; > > window.onbeforeunload = function () { > if ((form && form.$dirty) || (scope.$parent.form && scope.$parent.form.$dirty) || element.hasClass('ng-dirty')) { > return resourceFactory.getResource('Messages', 'unsavedChanges'); > } > }; > > var stateChange = function (event, toState, toParams) { > > if ((form && !form.$dirty) || (scope.$parent.form && !scope.$parent.form.$dirty)) { > onRouteChangeOff(); > return; > } > > event.preventDefault(); > > var modal = $modal.open({ > controller: function ($scope) { > $scope.okClass = 'btn-primary', > $scope.okLabel = resourceFactory.getResource('Labels', 'yes'), > $scope.cancelLabel = resourceFactory.getResource('Labels', 'cancel'), > $scope.title = resourceFactory.getResource('Labels', 'unsavedChanges'), > $scope.message = resourceFactory.getResource('Messages', 'unsavedChanges'); > }, > templateUrl: '/app/templates/modal' > }); > > modal.result.then(function () { > onRouteChangeOff(); > > if (scope.onOk != null) { > scope.onOk(); > } > $state.go(toState, toParams); > }); > }; > > var onRouteChangeOff = $rootScope.$on('$stateChangeStart', stateChange); > } > }; > }]);>
> <div class="col-lg-3 col-md-3 panel-container"> > <ul class="nav nav-pills nav-stacked"> > <li class="active"><a data-toggle="pill" href="#general" ng-class="{true: 'invalid-tab', false: ''}[form.editOperatorGeneralForm.$invalid]">@Labels.general</a></li> > <li><a data-toggle="pill" href="#secRoles">@Labels.roleMembership</a></li> > <li><a data-toggle="pill" href="#udf" ng-class="{true: 'invalid-tab', false: ''}[form.editOperatorUserFieldsForm.$invalid]">@Labels.userDefined</a></li> > <li><a data-toggle="pill" href="#eMsg">@Labels.eMessages</a></li> > <li><a data-toggle="pill" href="#notes">@Labels.notes</a></li> > </ul> > </div> > > <div class="col-lg-9 col-md-9 panel-container"> > <div class="tab-content"> > <div class="tab-pane active" id="general"> > @Html.Partial("EditOperatorGeneral") > </div> > <div class="tab-pane" id="secRoles"> > @Html.Partial("EditOperatorSecurityRoles") > </div> > <div class="tab-pane" id="udf"> > @Html.Partial("EditOperatorUserFields") > </div> > <div class="tab-pane" id="eMsg"> > @Html.Partial("EditOperatorEMessages") > </div> > <div class="tab-pane" id="notes"> > @Html.Partial("EditOperatorNotes") > </div> > </div> > </div>>
><div class="col-lg-2 col-md-2 panel-container"> > > <tabset vertical="true" type="pills"> > <tab ng-repeat="tab in tabsViews" select="selectView(tab.name, tab.index)" > ng-show="tab.isVisible" > class=" {{tabsViews[tab.index-1]['invalid'] ? 'invalid-tab': 'valid-tab' }}"> > <tab-heading>{{tab.title}}</tab-heading> > </tab> > </tabset> > > </div>>
<!DOCTYPE html> >><html ng-app="nestedForms" xmlns="http://www.w3.org/1999/xhtml"> >><head> >> <title>Nested Forms</title> >> <script src="../../Scripts/angular.js"></script> >> <script src="../../Scripts/angular-ui-router.js"></script> >></head> >><body> >> <script type="text/javascript"> >> var app = angular.module('nestedForms', ['ui.router']); >> app.config(function ($stateProvider, $urlRouterProvider) { >> $stateProvider.state('child', { >> template: '<ng-form name="childForm" ng-controller="childController"><input name="childInput" ng-model="childText" required /></ng-form>', >> controller: childController >> }); >> }); >> app.controller('mainController', mainController); >> app.controller('childController', childController); >> //Main Form Controller >> function mainController($scope,$state) { >> $scope.mainText = "Main Form Text"; >> $scope.loadView = function () { >> $state.go('child'); >> }; >> } >> //Child Form Controller >> function childController($scope) { >> $scope.childText = "Child Form Text"; >> } >> </script> >> >> <ng-form name="mainForm" ng-controller="mainController"> >> <input name="mainInput" ng-model="mainText" required /> >> <input type="button" value="Load Child View" ng-click="loadView()"/> >> <div>Main Form valid:{{mainForm.$valid}}</div> >> <section ui-view></section> >> </ng-form> >></body> >></html>