有人能告訴我奠定了結構爲我的第一個角項目的正確方法是什麼?
概述
這是我的第一個角的項目,我希望得到的結構正確之前,我走的更遠。
我正在構建一個具有多個部分和功能的窗體。
我在網上看到很多不同的想法,主要針對大型項目,而不是針對小型初學者項目,所以我希望有人可以幫助我獲得主演。
當前結構
所有形式的文件是我的表格的不同部分。
app.js
// app.js
// create our angular app and inject ngAnimate and ui-router
// =============================================================================
angular.module('formApp', ['ngAnimate', 'ui.router'])
// configuring our routes
// =============================================================================
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
// route to show our basic form (/form)
.state('form', {
url: '/form',
templateUrl: 'form.html',
controller: 'formController'
})
// nested states
// each of these sections will have their own view
// url will be nested (/form/signup)
.state('form.signup', {
url: '/signup',
templateUrl: 'form-signup.html'
})
// url will be /form/select
.state('form.select', {
url: '/select',
templateUrl: 'form-select.html'
})
// url will be /form/type
.state('form.type', {
url: '/type',
templateUrl: 'form-type.html'
});
// catch all route
// send users to the form page
$urlRouterProvider.otherwise('/form/signup');
})
// our controller for the form
// =============================================================================
.controller('formController', function($scope) {
// we will store all of our form data in this object
$scope.formData = {};
// function to process the form
$scope.processForm = function() {
alert('awesome!');
};
});
test.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function ($scope) {
$scope.user = {bankName: ''};
$scope.banks = [{
"name": "Bank A",
"branches": [{
"name": "Branch 1",
"code": "1"
}, {
"name": "Branch 2",
"code": "2"
}]
}, {
"name": "Bank B",
"branches": [{
"name": "Branch 3",
"code": "3"
}, {
"name": "Branch 4",
"code": "4"
}, {
"name": "Branch 5",
"code": "5"
}]
}];
});
看看這個角度發生器提供 –
hmm yeoman看起來很有趣+1感謝提供的信息 – Beep
看看[John Papa的LIFT Principle](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#application-structure - 電梯原理)。這將幫助您瞭解您的應用程序結構 – Kanagu