管理表單示例

管理表單示例

image

目錄結(jié)構(gòu):

image

index.html:

<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title>index</title>
    <link rel="stylesheet" href="../vendor/bootstrap3/css/bootstrap.css">
    <link rel="stylesheet" href="index.css">

    <script src="../vendor/bootstrap3/js/jquery.js"></script>
    <script src="../vendor/bootstrap3/js/bootstrap.js"></script>
    <script src="../vendor/bootstrap3/js/angular.js"></script>
    <script src="index.js"></script>
</head>
<body ng-controller="ctrl">

<div>
    <table id="clusterTable" class="table table-bordered table-hover">
        <thead>
        <tr>
            <th>序號</th>
            <th>集群名稱</th>
            <th>創(chuàng)建者</th>
            <th>創(chuàng)建時(shí)間</th>
            <th>狀態(tài)信息</th>
            <th>查看詳情</th>
        </tr>
        </thead>

        <tbody>
        <tr ng-repeat="item in clusterGroups">
            <td>{{item.id}}</td>
            <td>{{item.name}}</td>
            <td>{{item.owner}}</td>
            <td>{{item.date}}</td>
            <td>{{item.state}}</td>
            <td style="width: 300px; text-align: center">
                <button class="btn btn-success">啟動全部</button>
                <button class="btn btn-danger">停止全部</button>
                <slide-down></slide-down>
            </td>
        </tr>
        </tbody>
    </table>
</div>

</body>
</html>

index.js:

(function () {
    angular
        .module("app", [])
        .controller("ctrl", ["$scope", "$http", function ($scope, $http) {
            $scope.clusterGroups = [];
            $http.get("./clusterGroups.json").then(
                function (res) {
                    $scope.clusterGroups = res.data;
                },
                function (res) {
                    console.log(res);
                }
            )
        }])
        .directive("slideDown", function ($compile) {
            return {
                restrict: 'AE',
                replace: true,
                template: `<button class="btn btn-primary" ng-click="showDetails()">展開集群</button>`,
                link: function (scope, element, attributes, controller) {
                    let html = `<cluster-details item-id="item.id"></cluster-details>`;

                    element.tog = false;
                    scope.showDetails = function () {
                        if (element.tog === false) {
                            $(element).children("button").text("折疊集群");
                            $(element).parent().parent().after($compile(html)(scope));
                            element.tog = true;
                        } else {
                            $(element).children("button").text("展開集群");
                            $(element).parent().parent().next().remove();
                            element.tog = false;
                        }
                    }
                }
            }
        })
        .directive("clusterDetails", ["$http", function ($http) {
            return {
                restrict: 'AE',
                replace: true,
                scope: {
                    itemId: "=itemId"
                },
                templateUrl: "./clusterDetails.html",
                link: function (scope, element, attributes, controller) {
                    scope.cluster = [];
                    $http.get("./cluster/cluster_" + scope.itemId + ".json").then(
                        function (res) {
                            scope.cluster = res.data;
                        },
                        function (res) {
                            console.log(res);
                        }
                    );
                }
            }
        }])
})();

clusterDetails.html:

<tr>
    <td colspan="100" style="padding: 5px; background-color: #efefef;">
        <table class="table table-bordered table-hover" style="width: 100%; margin: 0;">
            <thead>
            <tr>
                <th>序號</th>
                <th>地址</th>
                <th>端口</th>
                <th>目錄</th>
                <th>狀態(tài)</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="item in cluster">
                <td>{{item.id}}</td>
                <td>{{item.ip}}</td>
                <td>{{item.port}}</td>
                <td>{{item.dir}}</td>
                <td>{{item.state}}</td>
                <td style="width: 200px; text-align: center">
                    <button class="btn btn-success">啟動</button>
                    <button class="btn btn-danger">停止</button>
                    <button class="btn btn-primary">命令</button>
                </td>
            </tr>
            </tbody>
        </table>
    </td>
</tr>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末泊交,一起剝皮案震驚了整個(gè)濱河市饱狂,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,470評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)铅乡,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,393評論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來烈菌,“玉大人阵幸,你說我怎么就攤上這事⊙渴溃” “怎么了挚赊?”我有些...
    開封第一講書人閱讀 162,577評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長济瓢。 經(jīng)常有香客問我荠割,道長,這世上最難降的妖魔是什么旺矾? 我笑而不...
    開封第一講書人閱讀 58,176評論 1 292
  • 正文 為了忘掉前任蔑鹦,我火速辦了婚禮,結(jié)果婚禮上箕宙,老公的妹妹穿的比我還像新娘嚎朽。我一直安慰自己,他們只是感情好柬帕,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,189評論 6 388
  • 文/花漫 我一把揭開白布哟忍。 她就那樣靜靜地躺著,像睡著了一般陷寝。 火紅的嫁衣襯著肌膚如雪锅很。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,155評論 1 299
  • 那天盼铁,我揣著相機(jī)與錄音粗蔚,去河邊找鬼尝偎。 笑死饶火,一個(gè)胖子當(dāng)著我的面吹牛鹏控,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播肤寝,決...
    沈念sama閱讀 40,041評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼当辐,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了鲤看?” 一聲冷哼從身側(cè)響起缘揪,我...
    開封第一講書人閱讀 38,903評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎义桂,沒想到半個(gè)月后找筝,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,319評論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡慷吊,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,539評論 2 332
  • 正文 我和宋清朗相戀三年袖裕,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片溉瓶。...
    茶點(diǎn)故事閱讀 39,703評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡急鳄,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出堰酿,到底是詐尸還是另有隱情疾宏,我是刑警寧澤,帶...
    沈念sama閱讀 35,417評論 5 343
  • 正文 年R本政府宣布触创,位于F島的核電站坎藐,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏哼绑。R本人自食惡果不足惜顺饮,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,013評論 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望凌那。 院中可真熱鬧兼雄,春花似錦、人聲如沸帽蝶。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,664評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽励稳。三九已至佃乘,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間驹尼,已是汗流浹背趣避。 一陣腳步聲響...
    開封第一講書人閱讀 32,818評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留新翎,地道東北人程帕。 一個(gè)月前我還...
    沈念sama閱讀 47,711評論 2 368
  • 正文 我出身青樓住练,卻偏偏與公主長得像,于是被迫代替她去往敵國和親愁拭。 傳聞我的和親對象是個(gè)殘疾皇子讲逛,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,601評論 2 353

推薦閱讀更多精彩內(nèi)容

  • 1 Webpack 1.1 概念簡介 1.1.1 WebPack是什么 1、一個(gè)打包工具 2岭埠、一個(gè)模塊加載工具 3...
    Kevin_Junbaozi閱讀 6,659評論 0 16
  • 1盏混、通過CocoaPods安裝項(xiàng)目名稱項(xiàng)目信息 AFNetworking網(wǎng)絡(luò)請求組件 FMDB本地?cái)?shù)據(jù)庫組件 SD...
    陽明先生_X自主閱讀 15,979評論 3 119
  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML標(biāo)準(zhǔn)惜论。 注意:講述HT...
    kismetajun閱讀 27,474評論 1 45
  • 2017年3月22日中午1點(diǎn)许赃,對于我來說是個(gè)值得紀(jì)念的日子,在這個(gè)地球上生長了24年馆类,第一次被狗咬图焰,還是一個(gè)只有四...
    蹲在墻角等月亮閱讀 387評論 0 0
  • 不要為不值得的人做太多,不是因?yàn)椴粔驉郾钠菒圻^了自己能夠承受的范圍卻又無法得到回報(bào)技羔,反而是作踐自己。 這種犯賤的...
    昏鈍年華閱讀 320評論 0 2