我收到错误:[ng:areq]参数'employeeObj'不是函数,未定义,我无法弄清楚我错过了什么。有谁能够帮我?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<script src="Scripts/angular.js"></script>
<script>
"use strict"
function Employee($scope, $rootScope) {
debugger;
$rootScope.counter = (($rootScope.counter||0)+1);
$scope.FirstName = "demo";
$scope.LastName = "demo";
$scope.Validate = function () {
if ($scope.FirstName == 0 || $scope.LastName == 0) {
alert("No!")
} else {
alert("Yes!")
}
}
}
var empApp = angular.module("employeeApp", []);
empApp.controller = ("employeeObj", Employee);
</script>
<body>
<div ng-app="employeeApp">
<div id="empScreen" ng-controller="employeeObj">
First Name: <input ng-model="FirstName" id="FirstName" type="text" value=" " /><br />
Last Name: <input ng-model="LastName" id="LastName" type="text" value=" " /><br />
{{FirstName}}<br />
{{LastName}}<br />
{{counter}}<br />
<input type="button" value="Validate" ng-click="Validate()" />
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
如果您使用1.3以上的角度版本,则需要定义这样的控制器,
{% extends "fc/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-success active" role="progressbar" aria-valuenow="87.5" aria-valuemin="0" aria-valuemax="100" style="width: 87.5%">
<span class="sr-only">87.5% Complete</span>
</div>
</div>
<div class="panel panel-default box-shadow--16dp col-sm-6 col-sm-offset-3">
<div class="panel-body">
<div class='row'>
<div class='col-sm-12'>
<h3>Setup | Add Episode</h3>
<h4>Twitter - Guest Click-To-Tweet</h4>
<h5>FC will also build the ‘clickable tweet’ which will be automatically sent in the body of the mail to your guest on the morning of the episode goes live.</h5>
<hr/>
<form method='POST' action=''>{% csrf_token %}
{{ form|crispy }}
<hr/>
<button type="submit" class="btn btn-primary box-shadow--6dp"><i class="fa fa-chevron-right pull-right"></i> Continue
</button>
</form>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
答案 1 :(得分:-1)
尝试在角度部分的控制器实现中进行此更改:
var empApp = angular.module("employeeApp", []);
empApp.controller('employeeObj', Employee); // <-- change here
<强> 之前 强>
empApp.controller = ('employeeObj', Employee); <-- remove the equal sign