【发布时间】:2023-03-23 04:48:01
【问题描述】:
我看过很多关于 codeigniter 和 angularjs 一起工作的帖子,但大多数都是关于检索数据和传递数据的。我的问题更基本。
我通过php运行站点,然后一切正常,这意味着angularjs可以正常工作。但是当我通过控制器运行它时,它没有工作。出了什么问题?这是我的部分代码:
<body ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
class First extends CI_Controller{
public function index(){
$this->load->view('first');
}
}
var app = angular.module('myApp', ['ngMaterial']);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
我的控制器文件是first.php,查看文件也是first.php。当我通过http://localhost/ci_ngtest/index.php/first浏览网站时,输入的名字和姓氏都是空白的,全名显示{{firstName + " " + lastName}} 而不是 John Doe
这是我的项目结构:
--application
--node_modules
--angular
--angular.js
--angular-material
--system
--user_guide
--somefiles(somefiles below)
【问题讨论】:
-
您在哪里添加了
angularjs库...? -
在正文中,
-
我还添加了
-
在控制台中检查您遇到了什么错误..?
-
加载失败:localhost/node_modules/angular/angular.js 资源服务器响应状态为 404(未找到)
标签: angularjs codeigniter codeigniter-3