1.主页面通过路由控制页面的跳转和参数传递:
.state('namesAdd', { url: "/names-add", templateUrl: "Scripts/spa/names-add.html", //对应的页面 //warning: true, resolve: { deps: requireJS([ 'names/namesAdd.controller' //绑定的JS ]) }, ncyBreadcrumb: { label: 'Add Name', parent: 'maintainVarietyNamesAddStart' //多级菜单的上一级名 } })
2.html页面的头部声明代码:
<div ng-controller="namesAddCtrl as namesAdd"> <form name="namesForm" ng-submit="namesAdd.addName(namesForm.$invalid)" novalidate> </form> </div>
3.对应的JS声明代码:
(function () { 'use strict'; define(['app', 'webApi/webapi', 'blocks/modal/modal'], function (app) { //angular // .module('sunflower') app.controller('namesAddCtrl', namesAddCtrl); namesAddCtrl.$inject = ['$http', '$state', '$stateParams', 'logger', 'uiGridConstants', 'webapi', '$scope', '$uibModal', 'modal']; function namesAddCtrl($http, $state, $stateParams, logger, uiGridConstants, webapi, $scope, $uibModal, modal) { }; }) })();