【发布时间】:2021-01-11 16:09:25
【问题描述】:
我是 Angular Js 的新手。
在刀片文件中使用角度变量,我收到以下错误:
使用未定义的常量计数 - 假定为“计数”(查看:C:\xampp\htdocs\angularjsLaravel\resources\views\testing.blade.php)
我的代码,
app.js
var app = angular.module('employeeRecords', []);
(function (app) {
"use strict";
app.controller("EmployeesController", function ($scope, $http) {
$http({
method: 'GET',
url: '/employees'
}).then(function (employees){
$scope.employees = employees['data'];
},function (error){
console.log(error);
});
$scope.remaining = function () {
var count = 0;
angular.forEach($scope.employees, function (employee) {
count += employee.done ? 0 : 1;
});
}
});
})(app);
blade.php
<div id="employee" ng-controller="EmployeesController">
<h3 class="page-header">
<small ng-if="remaining()">{{ count }}</small>
</h3>
</div>
帮帮我。
我期待一个解决方案。
【问题讨论】:
-
你得到了什么?
-
出现此错误:使用未定义的常量计数 - 假定为“计数”(查看:C:\xampp\htdocs\angularjsLaravel\resources\views\testing.blade.php)
-
Blade 和 Angular 使用通用语法来显示变量,这就是问题所在。所以尝试改变角度变量打印的语法。 Blade 文件正在寻找 php 变量而不是 jquery。
标签: javascript php angularjs laravel