0
这是我第一次尝试使用angularJs组件,因此请耐心等待。任何想法为什么它不打印Hello World?使用Angularjs组件的简单Hello World
http://plnkr.co/edit/D3DMVAaechJUj4ZzPBDL?p=preview
的script.js
(function() {
'use strict';
angular
.module('myApp', [])
.component('sampleComponent', {
template: '<h1>Hello {{$ctrl.name}}!</h1>',
bindings: {
name: '<'
},
controller: function() {
//alert('here');
}
});
})();
的index.html
<!DOCTYPE html>
<html>
<head>
<script data-require="[email protected]" data-semver="1.6.2" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.js"></script>
<script data-require="[email protected]" data-semver="1.6.2" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular-route.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-app="myApp">
<sample-component name="World"></sample-component>
</body>
</html>