使用angular写一个hello world

2019-12-18,,,,

angularjs遵循MVC模式,惯例来一个hello world吧

复制代码 代码如下:
<html ng-app>
<head>
    <script type="text/javascript" src="angular.min.js"></script>
    <script type="text/javascript" src="controllers.js"></script>
</head>
<body>
    <div ng-controller='HelloController'>
        <p>{{greeting.text}}, world</p>
    </div>
</body>
</html>

controllers.js中的内容

复制代码 代码如下:
function HelloController($scope) {
    $scope.greeting = { text: "Hello"};
}

MVC写起来很不错的感觉~~

您可能感兴趣的文章:

  • Android 初识 Helloworld 详解
  • 全民学编程之 Hello World
  • 从零学Python之hello world
  • hello world程序集锦
  • Cocos2d-x中调用Lua及HelloWorld.lua源码分解
  • Go语言hello world实例
  • AngularJS入门教程之Hello World!

《使用angular写一个hello world.doc》

下载本文的Word格式文档,以方便收藏与打印。