• AngularJS--day06-多控制器思想-协同开发-文件页分模块(在此文章没有体现出来)


    <<!DOCTYPE html>
    <html ng-app='app' ng-controller='mainController'>
        <head>
            <meta charset="utf-8">
            <title>多控制器思想-协同开发</title>
            <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
        </head>
        <body>
            <br /><br /><br />
            <div class="container" ng-controller='commentController'>
                <div class="row" >
                    <div class="col-xs-3"></div>
                    <div class="col-xs-6">
                        <!-- 评论模块 -->
                        <div class="input-group">
                            <input type="text" class="form-control" />
                            <span class="input-group-btn" ng-model='comt'>
                                <button class="btn btn-primary" ng-click='submitComment(comt)'>评论</button>
                            </span>
                        </div>
                        <!-- 评论标题 -->
                        <h2 ng-show='commentArr.length>0'>评论</h2><!-- 有显示 -->
                        <!-- 评论内容 -->
                        <ul class="list-group">
                            <li class="list-group-item" ng-repeat='comment in commentArr track by $index'>
                                <span>{{comment}}</span>
                                <a href="javascript:;" class="btn btn-link" ng-click='deleteComment($index)'>删除本条评论</a>
                            </li>
                        </ul>
                    </div>
                    <div class="col-xs-3"></div>
                </div>
            </div>
            <ul ng-controller='namelistController'>
                <li ng-repeat='liInfo in liInfoList track by $index'>{{liInfo}}</li>
            </ul>
            <script src="angular.js"></script>
            <script>
                var app = angular.module('app',[]);
                app.controller('mainController',['$scope',function($scope){
                    
                    
                }]);
                //评论控制器
                app.controller('commentController',['$scope',function ($scope){
                    $scope.commentArr = [];
                    //评论功能
                    $scope.submitComment = function (comt){
                        $scope.commentArr.push(comt);
                        $scope.comt = '';
                    };
                    //删除评论
                    $scope.deleteComment = function(index){
                        $scope.commentArr.splice(index,1);//.splice(index,howmany,item1,.....,itemX)index    必需。整数,规定添加/删除项目的位置,使用负数可从数组结尾处规定位置。
                    };
                }]);
                //名称列表控制器
                app.controller('namelistController',['$scope',function ($scope){
                    $scope.liInfoList = ['22','33','44'];
                }]);
            </script>
        </body>
    </html>
  • 相关阅读:
    POJ
    巧得int(4字节)最大最小值
    POJ
    POJ
    2018牛客暑期多校训练第三场——C Shuffle Cards(rope大法)
    共享一些知识点的学习地址
    webstorm的各种快捷键配置
    Remote Debugging Chrome 结合Genymotion模拟器的移动端web真机调试
    支持新版chrome,用webstorm编译形成css和sourcemap,调试sass和less源文件
    最新版phonegap3.5.1环境搭建
  • 原文地址:https://www.cnblogs.com/fdxjava/p/11423893.html
Copyright © 2020-2023  润新知