1
作爲一個學術項目,我期望創建一個可以顯示,創建和編輯多種類型筆記的AngularJS '小部件'。 我是AngularJS的新手。經過幾天的搜索互聯網的主題像AngularJS 部件,自定義指令和智能表,我很困惑,仍然不確定如何開始這個項目。 我的問題是兩部分:1。 如何建立這個「筆記」模塊(?控件),這樣以後就可以嵌入在一個較大的應用程序?是定製指令開始呢? 2.我試圖創建一個示例智能表這樣的(見下文),但儘管包括智能table.js,'st-table'
仍顯示爲一個「未知屬性」。 這裏是我的樣品智能表代碼:在AngularJS中創建一個小部件並使用智能表
var app = angular.module('myApp', ['smart-table']);
//The controller with the notes data.
app.controller('notesController', function ($scope) {
$scope.notes = [
{
"NoteID": "TL001",
"NoteType": "TL",
"NoteCreator": "XYZ",
"NoteCreationTime": "12/12/2015 12:32:52",
"NoteDescription": "Here is some sample description for this sample note.",
},
{
"NoteID": "SL001",
"NoteType": "SL",
"NoteCreator": "ABC",
"NoteCreationTime": "12/12/2015 12:32:52",
"NoteDescription": "Here is some sample description for this sample note.",
},
{
"NoteID": "OL002",
"NoteType": "OL",
"NoteCreator": "MNO",
"NoteCreationTime": "1/7/2015 11:01:50",
"NoteDescription": "Here is some sample description for this sample note.",
},
];
});
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>Really Simple Table</title>
<script src="../Scripts/angular.js"></script>
<script src="smart-table.js"></script>
<script src="ReallySimpleTable.js"></script>
</head>
<body>
<div ng-controller="notesController">
<table st-table="notes" class="table table-striped">
<th>Note ID</th>
<th>Note Type</th>
<th>Note Creator</th>
<th>Note Creation Time</th>
<th>Note Description</th>
<tr ng-repeat="note in notes">
<td> {{ note.NoteID }} </td>
<td> {{ note.NoteType }} </td>
<td> {{ note.NoteCreator }} </td>
<td> {{ note.NoteCreationTime }} </td>
<td> {{ note.NoteDescription }} </td>
</tr>
</table>
</div>
</body>
</html>
感謝。