<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.0.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js" data-semver="1.0.7"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<h2>By my-address directive</h2>
<div my-address></div>
<h2>By ng-include</h2>
<div ng-include='"address.html"'></div>
</body>
</html>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
app.directive("myAddress", function() {
return {
restrict: "A",
templateUrl: "address.html",
replace: true
}
})
/* Put your css in here */
label {
display: block;
width: 250px;
text-align: right;
}
<div class="address">
<label>
国家:<input type="text" ng-model="country" />
</label>
<label>
城市:<input type="text" ng-model="city" />
</label>
<label>
街道详情:<input type="text" ng-model="address" />
</label>
<label>
邮编:<input type="text" ng-model="zipcode" />
</label>
</div>