AngularJS文本框返回未定义的值
当我在引导模式中按下check按钮时,我想在控制台中打印文本框的值。但是我的文本框返回一个未定义的。似乎所有的代码都工作得很完美AngularJS文本框返回未定义的值,angularjs,Angularjs,当我在引导模式中按下check按钮时,我想在控制台中打印文本框的值。但是我的文本框返回一个未定义的。似乎所有的代码都工作得很完美 <!doctype html> <html ng-app="app" ng-controller="ModalDemoCtrl"> <head> <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="styleshee
<!doctype html>
<html ng-app="app" ng-controller="ModalDemoCtrl">
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
<script src="example1.js"></script>
</head>
<body>
<div ><button class="btn btn-default" ng-click="open('lg')" >Large modal</button>
<script type="text/ng-template" id="myModalContent">
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<input type="text" ng-model="new1" /><button ng-click="check()" >check</button>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
</script>
</div>
</body>
</html>
在对象初始化而不是范围上声明新属性:
var ModalInstanceCtrl = function ($scope,$rootScope, $modalInstance) {
$scope.model= {};
$scope.check = function()
{
alert($scope.model.new);
};
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
在对象初始化而不是范围上声明新属性:
var ModalInstanceCtrl = function ($scope,$rootScope, $modalInstance) {
$scope.model= {};
$scope.check = function()
{
alert($scope.model.new);
};
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
在对象初始化而不是范围上声明新属性:
var ModalInstanceCtrl = function ($scope,$rootScope, $modalInstance) {
$scope.model= {};
$scope.check = function()
{
alert($scope.model.new);
};
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
在对象初始化而不是范围上声明新属性:
var ModalInstanceCtrl = function ($scope,$rootScope, $modalInstance) {
$scope.model= {};
$scope.check = function()
{
alert($scope.model.new);
};
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
要访问$scope变量,您需要使用$parent,因为它正在模式中创建子作用域 HTML代码(此代码已更改):
检查
要访问$scope变量,您需要使用$parent,因为它正在模式中创建子作用域 HTML代码(此代码已更改):
检查
要访问$scope变量,您需要使用$parent,因为它正在模式中创建子作用域 HTML代码(此代码已更改):
检查
要访问$scope变量,您需要使用$parent,因为它正在模式中创建子作用域 HTML代码(此代码已更改):
检查
您可以在“检查”功能中将ng模型作为参数传递
检查
$scope.check=函数(new1)
{
console.log(“值…”+new1);
};
您可以在“检查”功能中将ng模型作为参数传递
检查
$scope.check=函数(new1)
{
console.log(“值…”+new1);
};
您可以在“检查”功能中将ng模型作为参数传递
检查
$scope.check=函数(new1)
{
console.log(“值…”+new1);
};
您可以在“检查”功能中将ng模型作为参数传递
检查
$scope.check=函数(new1)
{
console.log(“值…”+new1);
};
你能为它拉小提琴吗?我有plunker link…你能为它拉小提琴吗?我有plunker link…你能为它拉小提琴吗?我有plunker link…你能为它拉小提琴吗?我有plunker link。。。