gpt4 book ai didi

javascript - AngularJS 函数调用导致应用程序停止

转载 作者:行者123 更新时间:2023-12-03 06:27:26 24 4
gpt4 key购买 nike

看这段代码:

// Start AngularJS Application
var application = angular.module('engineers', []);
// Set controller
application.controller('engineers_controller', function($scope) {
// Seting page meta information
$scope.description = 'Some Description', $scope.keywords = 'key1,key2,key3', $scope.application_name = 'Sarabon', $scope.googleplus_url = '#', $scope.page_title = 'مهندسین مشاور سرابن',
$scope.txt1="Well, the way they make shows is, they make one show. That show's called a pilot. Then they show that show to the people who make shows, and on the strength of that one show they decide if they're going to make more shows. Some pilots get picked and become television programs. Some don't, become nothing. She starred in one of the ones that became nothing.",
$scope.txt2="You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.",
$scope.switch1=function(){
$scope.activetext=$scope.txt1,
$scope.firstswitcher='fa fa-square';
$scope.secondswitcher='fa fa-square-o';
},
$scope.switch2=function(){
$scope.activetext=$scope.txt2,
$scope.secondswitcher='fa fa-square';
$scope.firstswitcher='fa fa-square-o';
};
switch1();
});

我尝试调用switch1()函数onpageloads。但是当我运行我的页面时,几乎所有页面都被破坏并且无法正常工作。当我从代码中删除 switch1(); 时,它再次正常工作。代码有什么问题吗?我怎样才能正确地做到这一点?

最佳答案

函数switch1不存在。您可能想改为编写 $scope.switch1();

关于javascript - AngularJS 函数调用导致应用程序停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38588025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com