0
我來這裏是因爲我不能夠讓我的控制器看到我的HTML變量我們的功能,也許你們看到的東西我不=(角 - 控制器不能看到我的變量在HTML
HTML:
<article ng-controller="CreateUserController">
<div class="well">
<center>
<h1>Registrar</h1> <button ng-click="test()">Teste</button>
</br>
<form name="form">
<div class="form-group has-feedback"
ng-class="{
'has-error': form.name.$invalid && form.name.$dirty,
'has-success': form.name.$valid && form.name.$touched
}">
<div>
<input ng-disabled="true" type="name" required name="name" class="form-control" placeholder="Nome" ng-model="user.name">
<p class="help-block" ng-messages="form.name.$error">
<span ng-message="required">Nome esta vazio.</span>
</p>
</div>
</div>
</form>
</center>
</div>
</article>
JS:
angular.module('auth').controller('CreateUserController', [
'$scope', '$http', '$location','$state','$routeParams', '$modal','$rootScope',"$resource","Auth",'UserCompaniesService',
function($scope, $http, $location,$state,$routeParams, $modal,$rootScope,$resource,Auth,UserCompaniesService){
$scope.signedIn = Auth.isAuthenticated;
$scope.logout = Auth.logout;
var Account = $resource('/accounts/'+$routeParams.id+'.json',
{},
{ "show": { "method": "GET" }});
account = Account.get({"account_id":$routeParams.id});
//Not being seen
$scope.test = function() {
alert('teste');
}
$scope.user.name = account.name;//$scope.user is not being seen
$scope.user.email = account.email;
user.html.erb
<article ng-app="auth">
<div ng-view></div>
</article>
你們能幫我嗎?
歡迎來到SO。請提供一些關於您正在經歷什麼的信息?請儘可能具體。你在控制檯中看到任何javascript錯誤嗎? AngularJS對輸出非常具體的信息非常好,可以幫助你。 – ragerory
你在哪裏提交表格?也許你需要檢查ng-submit指令併爲它分配一個函數。 – pro
請把它放到plunker中:http://plnkr.co/ –