<!doctype html>
<html>
<head>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="angular-1.0.1.min.js" type="text/javascript"></script>
</head>
<body>
<div ng-app="app" ng-controller="parentCtr" id="testdiv">
</div>
</body>
<script>
angular.module("app", []).controller("parentCtr",
function ($scope,$compile) {
var html = ‘<div>name :<input ng-model="name" type="text" ng-change="change()" /></div>‘;
$("#testdiv").html(
$compile(html)($scope)
);
$scope.change = function (){
console.log("hellojava");
};
});
</script>
</html
时间: 2024-10-10 23:25:41