我想对接收的其他输入的值输入使用NG-模型...使用NG-模式,相同的值
我的代码不工作,我不理解为什么,是否可以将ng-model设置为具有Angular值的输入?
我的代码
var BottomApp = angular.module('BottomApp', []);
BottomApp.controller('SeoArticle', ['$scope', function($scope) {
$scope.seoTitle = document.getElementById('title').value;
$scope.createSeoUrl = function(string){
var string;
string = string.replace(/'+/g, '');
string = string.replace(/"+/g, '');
return string.replace(/\s+/g, '-');
};
}]);
<div ng-controller="SeoArticle">
<input type="text" id="title" name="article[title]" class="form-control" placeholder="title" ng-model="seoTitle">
<input type="text" name="article[seo_title]" value="{{seoTitle2}}">
<input type="text" name="article[seo_url]" value="{{seoUrl2}}">
<div class="ui-block-title"><h5>{{seoTitle}}</h5></div>
<input type="text" id="title" class="form-control" placeholder="title" value="{{seoTitle}}" ng-model="seoTitle2">
<input type="text" id="seo_url" class="form-control" placeholder="seo_url" value="{{createSeoUrl(seoTitle)}}" ng-model="seoUrl2">
<div class="panel">
<div class="seo-overview">
<p class="seo-overview-title">{{seoTitle}}</p>
<p class="seo-overview-url">{{createSeoUrl(seoTitle)}}</p>
</div>
</div>
</div>
:
我建议建立为说明这一点,你问这个概念的问题一个简单的示例。 – Kolban 2014-12-01 15:54:42
我注意到的冷杉事件是createSeoUrl有一个名为'string'的参数,里面有一个名为'string'的变量。 – 2014-12-01 15:58:07
是的我改变了它,但这不是问题... – tonymx227 2014-12-01 16:07:02