angularJS 入门基础(3)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>angular</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <script src=""></script>
    <script src=""></script>
    <link href="">
    <script src="" type="text/javascript"></script>
</head>
<body ng-app="app">
    <script type="text/javascript">
           var app = angular.module("app",[]);
    </script>
    <div>
        <div>
            angular中的factory就相当于一个公用的实例方法,可以理解为一个多个控制器都可以用的函数;
        </div>
        <div  ng-controller="factory">
            {{json}}
            <script>
                app.factory("ff", function() {
                    return {
                        "noting" : "json"
                    };
                });
                app.controller("factory", function($scope, ff) {
                    $scope.json = ff;
                });
            </script>
        </div>
    </div>
    <div>
        <div>
            angular的指令;
        </div>
        <div>
            <heh>do you content for?</heh>
            <script>
                app.directive("heh", function() {
                    return {
                        restrict : "AE",
                        replace : true,
                        transclude : true,
                        template : '<div> <button ng-transclude></button></div>'
                    };
                })
            </script>
        </div>
    </div>

</body>
</html>

.ng-switch指令的使用(这个跟模板很想的,就是我们常见的点击隐藏和显示Tab插件的angular首先)::

复制代码 代码如下:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgfxjj.html